http://poj.org/problem?id=3331
The Idiot of the Year Contest!
Time Limit:2000MS |
|
Memory Limit:65536K |
Total Submissions:3072 |
|
Accepted:1590 |
Description
There is just one basic rule in the Idiot of the Year Contest (IYC)! The contestant picks a random digit between 0 and 9, computes the factorial of the day of the year he/she is born, and counts the how many times the digit picked appears in the factorial. The contestant with highest count is the Idiot of the Year! For example, if you are born on 5th of Mordad which is the 129th day of the year, and you pick the digit 6, your score will be the number of times the digit 6 appears in 129! (that is 1 × 2 × 3 × ... × 129).
The chief judge of IYC wants you to write a program to get an integer which is the day of the year a contestant is born on and a digit and report the number of times the digit appears in the factorial of the first number.
Input
The first line of the input contains a single integerTwhich is the number of test cases, followed byTlines each containing the data for a test case having two numbers. The first number is the day of the year a contestant is born and the second one is the digit he/she has picked.
Output
The output containsTlines, each having one integer which is the number of times the digit appears in the factorial of the first number.
Sample Input
2
5 2
7 0
Sample Output
1
2
分享到:
相关推荐
Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems....
北大POJ2151-Check the difficulty of problems 解题报告+AC代码
POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度POj 1001源代码——高精度乘单精度
北大POJ3083-Children of the Candy Corn 解题报告+AC代码
POJ2942-Knights of the Round Table 【Tarjan算法】 解题报告+AC代码 http://hi.csdn.net/!s/F3L8HO ================================== 我的POJ所有解题报告:...
poj 1611 The Suspects 代码 并查集的应用
poj 1001答案
北大POJ1426-Find The Multiple【BFS+同余模】 解题报告+AC代码
北大POJ1027-The Same Game 解题报告+AC代码
北大POJ2187-Beauty Contest 解题报告+AC代码
北大POJ1163-The Triangle 解题报告+AC代码
poj 3174 Alignment of the Planets.md
北大POJ1163-The Triangle
poj 1611 The Suspects.md
北大POJ2109-Power of Cryptography 解题报告+AC代码
poj 3191 The Moronic Cowmpouter.md
poj 1989 The Cow Lineup.md
poj 3260 The Fewest Coins.md
poj 3901 The Computer Game.md
先利用prim算法求出最小生成树,然后通过往MST里加边来判断新生成的最小生成树是否具有最小的权值,POJ上The Unique MST(1679)题是要求判断最小生成树是否唯一,此题其实根本不用这样做,但是为了练习球次小生成树...