hiho week 180 register

Ended

Participants:184

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-15 19:36:22

Lang:GCC

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <math.h>
int main(void)
{
    unsigned long long int y,l,k,a=9,n,s=0,d=0,c,q;
    int j,i,t;
    scanf("%llu",&n);
    if (n==0) printf("0");
    else
    {
      for (i=1;;i++)
        { s+=a*i;
          if (n<=s)
              break;
          a*=10;
        }
      s=s-a*i+1;
      l=n-s;
      k=l/i;
      y=l%i;
      for (d=1,t=1;t<=i-1;t++)
        d*=10;
      //d+=(int)pow(10,i-1);
      d=d+k;
      for (t=1,q=1;t<=i-y-1;t++)
        q*=10;
        c=d/q%10;
      //c=d/((int)pow(10,i-y-1))%10;
      printf("%llu",c);
    }
    return 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX