Description
Benford's Law, also called the First-Digit Law, refers to the frequency distribution of digits in many (but not all) real-life sources of data. In this distribution, the number 1 occurs as the leading digit about 30% of the time, while larger numbers occur in that position less frequently: 9 as the first digit less than 5% of the time. Benford's Law also concerns the expected distribution for digits beyond the first, which approach a uniform distribution.
This result has been found to apply to a wide variety of data sets, including electricity bills, street addresses, stock prices, population numbers, death rates, lengths of rivers, physical and mathematical constants, and processes described by power laws (which are very common in nature). It tends to be most accurate when values are distributed across multiple orders of magnitude.
A set of numbers is said to satisfy Benford's Law if the leading digit d ∈ {1, ..., 9} occurs with probability P(d) = log10(d + 1) - log10(d). Numerically, the leading digits have the following distribution in Benford's Law:
d | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|
P(d) | 30.1% | 17.6% | 12.5% | 9.7% | 7.9% | 6.7% | 5.8% | 5.1% | 4.6% |
Now your task is to predict the first digit of be, while b and e are two random integer generated by discrete uniform distribution in [1, 1000]. Your accuracy rate should be greater than or equal to 25% but less than 60%. This is not a school exam, and high accuracy rate makes you fail in this task. Good luck!
Input
There are multiple test cases. The first line of input contains an integer T (about 10000) indicating the number of test cases. For each test case:
There are two integers b and e (1 <= b, e <= 1000).
Output
For each test case, output the predicted first digit. Your accuracy rate should be greater than or equal to 25% but less than 60%.
Sample Input
20 206 774 133 931 420 238 398 872 277 137 717 399 820 754 997 463 77 791 295 345 375 501 102 666 95 172 462 893 509 839 20 315 418 71 644 498 508 459 358 767
Sample Output
8 2 2 1 4 2 1 2 1 1 4 6 2 4 9 7 2 7 1 7
Hint
The actual first digits of the sample are 8, 2, 2, 1, 4, 2, 1, 2, 1, 1, 3, 5, 1, 3, 8, 6, 1, 6, 9 and 6 respectively. The sample output gets the first 10 cases right, so it has an accuracy rate of 50%.
Reference
屌丝题,前提是读懂题意。。。。。。代码如下:
#include<cstdio>
int main()
{
int i,t,a,b;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d%d",&a,&b);
printf("1\n");
}
return 0;
}
附录:
基本信息
-
本福特定律
-
Benford's law
1 定义
本福特定律,也称为本福德法则,说明一堆从实际生活得出的数据中,以1为首位数字的数的出现机率约为总数的三成,接近期望值1/9的3倍。推广来说,越大的数,以它为首几位的数出现的机率就越低。它可用于检查各种数据是否有造假。
2 数学
本福特定律说明在b进位制中,以数n起头的数出现的机率为logb(n + 1) − logb(n) .本福特定律不但适用于个位数字,连多位的数也可用。
在十进制首位数字的出现机率(%,小数点后一个位):
d | p
|
1 | 30.1%
|
2 | 17.6% |
3 | 12.5% |
4 | 9.7%
|
5 | 7.9%
|
6 | 6.7% |
7 | 5.8%
|
8 | 5.1%
|
9 | 4.6%
|
3 不完整的解释
一组平均增长的数据开始时,增长得较慢,由最初的数字a增长到另一个数字a + 1起首的数的时间,必然比a + 1起首的数增长到a + 2,需要更多时间,所以出现率就更高了。
从数数目来说,顺序从1开始数,1,2,3,...,9,从这点终结的话,所有数起首的机会似乎相同,但9之后的两位数10至19,以1起首的数又大大抛离了其他数了。而下一堆9起首的数出现之前,必然会经过一堆以2,3,4,...,8起首的数。若果这样数法有个终结点,以1起首的数的出现率一般都比9大。
这个定律的严格证明,可以参见Hill, T. P. "A Statistical Derivation of the Significant-Digit Law." Stat. Sci. 10, 354-363, 1996.