Task: | Kyselyt |
Sender: | chobbit |
Submission time: | 2017-10-09 14:15:17 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.06 s | 1 | details |
#2 | WRONG ANSWER | 0.06 s | 2 | details |
#3 | RUNTIME ERROR | 0.21 s | 3 | details |
Code
#include <iostream> #include <math.h> int c(std::string x) { std::string::size_type sz; int a = (int)pow(10.0, (double)x.length() - 1.0); int b = std::stoi(x,&sz); if (b < 10) return b; if (b == a) { return 1; } if (b == (a + 1)) { return 0; } return b - (b/a); } int main() { int s; std::string out = ""; std::string y; std::cin >> s; for (int i = 0; i < s; ++i) { std::cin >> y; int n = c(y); out.append(std::to_string(n)); out.append("\n"); } std::cout << out; }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
1000 582 214 723 273 ... |
correct output |
---|
0 1 7 7 6 ... |
user output |
---|
577 212 716 271 476 ... Truncated |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 615664 916441 627600 279508 ... |
correct output |
---|
1 2 3 2 2 ... |
user output |
---|
615658 916432 627594 279506 126604 ... Truncated |
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 ... |
correct output |
---|
7 2 2 0 9 ... |
user output |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): stoi