Task: | Kyselyt |
Sender: | Nipatiitti |
Submission time: | 2017-10-11 16:14:30 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 25 |
#3 | ACCEPTED | 63 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.08 s | 1 | details |
#2 | ACCEPTED | 0.04 s | 2 | details |
#3 | ACCEPTED | 0.05 s | 3 | details |
Code
#include<iostream> #include<string> #include<vector> using namespace std; string e(vector<pair<unsigned long long int, unsigned long long int>> l, unsigned long long int i) { int k = 1; while(i > l[k-1].second) { k++; } unsigned long long int t = i - k*(-1 * l[k-2].first) - l[k-2].second; string e = to_string((t + k - 1) / k); int p = t % k; if (p != 0) { return string(1, e[p-1]); } return string(1, e[e.length()-1]); } int main() { string y = "9"; vector<pair<unsigned long long int, unsigned long long int>> l; l.push_back(make_pair(9, 9)); for (int i = 1; i < 18; i++) { y += "9"; l.push_back(make_pair(stoull(y), (l[i - 1].second + (stoull(y) - l[i - 1].first)*y.length()))); } unsigned long long int v; int r; cin >> r; for (int i = 0; i < r; i++) { cin >> v; if (v < 10) { cout << v << "\n"; continue; } cout << e(l, v) << "\n"; v = 0; } return 0; }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
1000 582 214 723 273 ... |
correct output |
---|
0 1 7 7 6 ... |
user output |
---|
0 1 7 7 6 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 615664 916441 627600 279508 ... |
correct output |
---|
1 2 3 2 2 ... |
user output |
---|
1 2 3 2 2 ... Truncated |
Test 3
Group: 3
Verdict: ACCEPTED
input |
---|
1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 ... |
correct output |
---|
7 2 2 0 9 ... |
user output |
---|
7 2 2 0 9 ... Truncated |