Task: | Kyselyt |
Sender: | Shrike |
Submission time: | 2017-10-03 09:28:44 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
#2 | RUNTIME ERROR | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | RUNTIME ERROR | 0.19 s | 1 | details |
#2 | RUNTIME ERROR | 0.19 s | 2 | details |
#3 | RUNTIME ERROR | 0.18 s | 3 | details |
Code
#include <iostream> #include <sstream> #include <string> #include <cmath> #include <algorithm> using namespace std; typedef long long ll; ll decade(ll n) { ll sum; sum = 0; for (int i = 1; i < 1000000; i++) { if (sum + i*9*pow(10.0, i-1) > n) return i; else sum += i*9*pow(10.0, i-1); } return 0; } ll sums(ll decade) { ll sum; sum = 0; for (int i = 1; i < decade; i++) sum += i*9*pow(10.0, i-1); return sum; } int main(int argc, char **argv) { int q; cin >> q; ll qs[q]; for (int i = 0; i < q; i++) { cin >> qs[i]; } for (int i = 0; i < q; i++) { ll inth, nth, dec, s, sm; dec = decade(qs[i]); s = sums(dec); sm = qs[i] - s; nth = (ll)ceil((double)sm/(double)dec); inth = nth % dec; stringstream ss; ss << nth; string str = ss.str(); reverse(str.begin(), str.end()); cout << str.at(str.length() - inth-1) << endl; } 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 |
---|
1 9 7 8 7 ... |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string...
Test 2
Group: 2
Verdict: RUNTIME ERROR
input |
---|
1000 615664 916441 627600 279508 ... |
correct output |
---|
1 2 3 2 2 ... |
user output |
---|
0 5 3 4 4 ... |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string...
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 ... |
correct output |
---|
7 2 2 0 9 ... |
user output |
---|
1 8 2 2 8 ... Truncated |
Error:
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string...