ZOJ 3793 First Digit

rt,直接猜1

First Digit


Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge



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 <= be <= 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

Benford‘s law in Wikipedia


Author: ZHOU, Yuchen

Source: ZOJ Monthly, June 2014

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int T_T;
    scanf("%d",&T_T);
    while(T_T--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        printf("1\n");
    }
    return 0;
}

ZOJ 3793 First Digit,布布扣,bubuko.com

时间: 2024-10-11 19:06:44

ZOJ 3793 First Digit的相关文章

ZOJ 3596 Digit Number(BFS)

Digit Number Time Limit: 10 Seconds      Memory Limit: 65536 KB Given an integer n and an integer m, please calculate the minimal multiple of n which consists of exactly m different digits. Input This problem has several test cases. The first line of

ZOJ 3891 K-hash

K-hash Time Limit: 2000ms Memory Limit: 131072KB This problem will be judged on ZJU. Original ID: 389164-bit integer IO format: %lld      Java class name: Main K-hash is a simple string hash function. It encodes a string Sconsist of digit characters

组队赛#1 解题总结 ZOJ 3803 YY&#39;s Minions (DFS搜索+模拟)

YY's Minions Time Limit: 2 Seconds      Memory Limit: 65536 KB Despite YY's so much homework, she would like to take some time to play with her minions first. YY lines her minions up to an N*M matrix. Every minion has two statuses: awake or asleep. W

HDU 1986 &amp; ZOJ 2989 Encoding(模拟)

题目链接: HDU: http://acm.hdu.edu.cn/showproblem.php?pid=1986 ZOJ: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1988 HDU 1987 & ZOJ 2990 和这题刚好相反,也是比较容易模拟: Chip and Dale have devised an encryption method to hide their (written) text messages

zoj 3827(牡丹江现场赛I题)

ZOJ Problem Set - 3827 Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information Theory is one of the most popular courses in Marjar University. In this course, there is an important chapter about informatio

ZOJ Problem Set - 3804 YY&#39;s Minions

学习:换一个角度考虑问题.YY's Minions Time Limit: 2 Seconds      Memory Limit: 65536 KB Despite YY's so much homework, she would like to take some time to play with her minions first. YY lines her minions up to an N*M matrix. Every minion has two statuses: awake

zoj 3430 Detect the Virus(AC自动机)

Detect the Virus Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Nobita found that his computer is extremely slow. After several hours' work, he finally found that it was a virus that made his poor computer slow and the virus was activated

POJ1607 &amp; HDU 1330 &amp; ZOJ 1216 Deck(数学题)

题目链接: POJ  1607 : http://poj.org/problem?id=1607 HDU 1330 :http://acm.hdu.edu.cn/showproblem.php?pid=1330 ZOJ  1216 : Description A single playing card can be placed on a table, carefully, so that the short edges of the card are parallel to the table

POJ 1150 The Last Non-zero Digit 数论+容斥

POJ 1150 The Last Non-zero Digit 数论+容斥 题目地址: POJ 1150 题意: 求排列P(n, m)后面第一个非0的数. 分析: 为了熟悉题目中的理论,我先做了俩初级的题目: POJ 1401,题解见:POJ 1401 && ZOJ 2202 Factorial 阶乘N!的末尾零的个数 NYOJ 954,题解见:NYOJ 954 求N!二进制末尾几个0 这题想了一下,十进制末尾几个0可以转化为几个5因子,二进制最后一位非0可以转化为2因子,但是10进制就