CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:Nanohenry
Submission time:2017-10-14 14:35:11 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1details
#20.05 s2details
#30.05 s3details

Compiler report

input/code.cpp: In function 'uint16_t getDiv(uint16_t)':
input/code.cpp:62:10: warning: large integer implicitly truncated to unsigned type [-Woverflow]
   return 100000;
          ^
input/code.cpp:64:10: warning: large integer implicitly truncated to unsigned type [-Woverflow]
   return 1000000;
          ^
input/code.cpp:66:10: warning: large integer implicitly truncated to unsigned type [-Woverflow]
   return 10000000;
          ^
input/code.cpp:68:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  return 100000000;
         ^

Code

#include <iostream>
#define dt uint16_t // 64 bit variables
using namespace std;
inline dt getDigits(dt value) { // Max 64 bit: ~9000000000000000000
if (value < 10) {
return 1;
} else if (value < 100) {
return 2;
} else if (value < 1000) {
return 3;
} else if (value < 10000) {
return 4;
} else if (value < 100000) {
return 5;
} else if (value < 1000000) {
return 6;
} else if (value < 10000000) {
return 7;
} else if (value < 100000000) {
return 8;
} else if (value < 1000000000) {
return 9;
} else if (value < 10000000000) {
return 10;
} else if (value < 100000000000) {
return 11;
} else if (value < 1000000000000) {
return 12;
} else if (value < 10000000000000) {
return 13;
} else if (value < 100000000000000) {
return 14;
} else if (value < 1000000000000000) {
return 15;
} else if (value < 10000000000000000) {
return 16;
} else if (value < 100000000000000000) {
return 17;
} else if (value < 1000000000000000000) {
return 18;
}
return 19;
}
inline dt getDiv(dt value) {
if (value == 0) {
return 0;
} else if (value == 1) {
return 1;
} else if (value == 2) {
return 10;
} else if (value == 3) {
return 100;
} else if (value == 4) {
return 1000;
} else if (value == 5) {
return 10000;
} else if (value == 6) {
return 100000;
} else if (value == 7) {
return 1000000;
} else if (value == 8) {
return 10000000;
}
return 100000000;
}
inline dt getDigit(dt value, dt index) {
return value / getDiv(getDigits(value) - index) % 10;
}
int main() {
dt amount;
cin >> amount;
dt *a = new dt[amount];
dt cur;
dt index;
dt size;
dt digits;
for (dt i = 0; i < amount; i++) {
cin >> a[i];
}
for (dt i = 0; i < amount; i++) {
cur = a[i];
index = 1;
size = 0;
digits = 0;
for (; size < cur; index++) {
size += getDigits(index);
}
cout << getDigit(index - 1, cur - (size + 1 - digits)) << '\n';
}
//while (1);
return 0;
}

Test details

Test 1

Group: 1

Verdict:

input
1000
582
214
723
273
...

correct output
0
1
7
7
6
...

user output
0
0
0
0
0
...
Truncated

Test 2

Group: 2

Verdict:

input
1000
615664
916441
627600
279508
...

correct output
1
2
3
2
2
...

user output
0
0
0
0
0
...
Truncated

Test 3

Group: 3

Verdict:

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
0
0
0
0
0
...
Truncated