We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7172d79 commit a9723b2Copy full SHA for a9723b2
CSES/Digit Queries.cpp
@@ -0,0 +1,46 @@
1
+#include<bits/stdc++.h>
2
+using namespace std;
3
+
4
+#define ll long long
5
+#define m 1e9+7
6
7
+int main()
8
+{
9
+ ios_base::sync_with_stdio(false);
10
+ cin.tie(NULL);
11
+ cout.tie(NULL);
12
13
+ int q;
14
+ cin>>q;
15
+ while(q--)
16
+ {
17
+ ll n,x,i;
18
+ cin>>n;
19
20
+ i=1;
21
+ x=1;
22
+ while(n>i*9*x)
23
24
+ n-=i*9*x;
25
+ i++;
26
+ x*=10;
27
+ }
28
29
+ if(n%i==0)
30
31
+ cout<<(x-1+n/i)%10;
32
33
34
+ else
35
36
+ ll y=x+n/i;
37
+ ll j=pow(10,i-n%i);
38
+ y/=j;
39
+ cout<<y%10;
40
41
+ cout<<"\n";
42
43
44
45
+}
46
0 commit comments