📄 toj_2903.cpp
字号:
/*2903. Number Sequence Time Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 66 Accepted Runs: 29This is simple a number sequence problem. In this problem a positive integer n will repeated n times. And number will start with 1 and continue to infinite.For example: if n is 11 then 11 will repeated 11 times.(11 11 11 11 11 11 11 11 11 11 11).In this problem you are expected to write a program that take a positive number p and display the digit of position p. p| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21d(p)| 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7Input:The input may contain multiple test cases. Each test case occupies a separate line and contains an integer n (1 ≤ n ≤ 199000000 ). The input terminates by end of file marker.Output:For each test case in the input output the digit of n position on a separate line.Sample Input:1111419212246474849Sample Output:1556671010Problem Setter: MD. SHAKIL AHMED.(CUET AGRODUT)Source: New Year Challenge Contest*/#include<cstdio>#include<cmath>#define MIN 1e-10int main(){ int p , dp; double dpPre; while ( scanf( "%d" , &p ) != EOF ) { dpPre = ( -1 + sqrt( 1 + 8 * p ) ) / 2; dp = static_cast< int >( dpPre ); printf( "%lf %d\n" , dpPre , dp ); if ( fabs( dpPre - dp ) > 1e-10 ) dp++; printf( "%d\n" , dp ); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -