CF913G.Power Substring

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given nn positive integers a1,a2,...,ana_{1},a_{2},...,a_{n} .

For every aia_{i} you need to find a positive integer kik_{i} such that the decimal notation of 2ki2^{k_{i}} contains the decimal notation of aia_{i} as a substring among its last min(100,length(2ki))min(100,length(2^{k_{i}})) digits. Here length(m)length(m) is the length of the decimal notation of mm .

Note that you don't have to minimize kik_{i} . The decimal notations in this problem do not contain leading zeros.

输入格式

The first line contains a single integer nn ( 1<=n<=20001<=n<=2000 ) — the number of integers aia_{i} .

Each of the next nn lines contains a positive integer aia_{i} ( 1<=ai<10111<=a_{i}<10^{11} ).

输出格式

Print nn lines. The ii -th of them should contain a positive integer kik_{i} such that the last min(100,length(2ki))min(100,length(2^{k_{i}})) digits of 2ki2^{k_{i}} contain the decimal notation of aia_{i} as a substring. Integers kik_{i} must satisfy 1<=ki<=10501<=k_{i}<=10^{50} .

It can be shown that the answer always exists under the given constraints. If there are multiple answers, print any of them.

输入输出样例

  • 输入#1

    2
    8
    2
    

    输出#1

    3
    1
    
  • 输入#2

    2
    3
    4857
    

    输出#2

    5
    20
    
首页