Task: | Kyselyt |
Sender: | Nanohenry |
Submission time: | 2017-10-14 14:36:51 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.24 s | 1 | details |
#2 | WRONG ANSWER | 0.06 s | 2 | details |
#3 | WRONG ANSWER | 0.07 s | 3 | details |
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; ^ input/code.cpp: In function 'int main()': input/code.cpp:82:5: warning: variable 'digits' set but not used [-Wunused-but-set-variable] dt digits; ^
Code
#include <iostream>#define dt uint16_t // 64 bit variablesusing namespace std;inline dt getDigits(dt value) { // Max 64 bit: ~9000000000000000000if (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 - getDigits(index))) << '\n';}//while (1);return 0;}
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
input |
---|
1000 582 214 723 273 ... |
correct output |
---|
0 1 7 7 6 ... |
user output |
---|
(empty) |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 615664 916441 627600 279508 ... |
correct output |
---|
1 2 3 2 2 ... |
user output |
---|
4 0 0 0 0 ... Truncated |
Test 3
Group: 3
Verdict: WRONG ANSWER
input |
---|
1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 ... |
correct output |
---|
7 2 2 0 9 ... |
user output |
---|
4 0 0 0 0 ... Truncated |