您的位置:首页 > 其它

“玲珑杯”ACM比赛 Round #19 A.A simple math problem【打表找规律】

2017-07-29 17:22 507 查看
A -- A simple math problem

Time Limit:2s Memory Limit:128MByte

Submissions:1568Solved:262

DESCRIPTION

You have a sequence anan,
which satisfies:



Now you should find the value of
⌊10an⌋⌊10an⌋.

INPUT

The input includes multiple test cases. The number of test case is less than 1000.Each test case contains only one integern(1≤n≤109)n(1≤n≤109)。

OUTPUT

For each test case, print a line of one number which means the answer.

SAMPLE INPUT

5
20
1314

SAMPLE OUTPUT

5
21
1317

SOLUTION

“玲珑杯”ACM比赛 Round #19

题目大意:

给你N,让你求出10^(an)

思路:

显然其随着n的递增,值也会递增。

前期n和ans基本等同,后期会增加一些值,所以我们暴力本地打表,得知什么时候能够将ans+1即可。

Ac代码:

#include<stdio.h>
#include<string.h>
using namespace std;
#define ll long long int
ll F[15]={11,100,999,9998,99997,999996,9999995,99999994,999999993};
int main()
{
ll n;
while(~scanf("%lld",&n))
{
ll output=n;
for(int i=0;i<=8;i++)
{
if(n>=F[i])output++;
}
printf("%lld\n",output);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息