Task: | Kyselyt |
Sender: | luxask |
Submission time: | 2017-10-06 19:51:08 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.04 s | 1 | details |
#2 | WRONG ANSWER | 0.05 s | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream> #include <vector> #include <math.h> using namespace std; vector<int> getIndexes() { int count, num; vector<int> indexes; cin >> count; for (int i = 0; i < count; ++i) { cin >> num; indexes.push_back(num); } return indexes; } int f(int x) { return 9 * x * pow(10, x-1); } int getFirstNumber(int index, int numCount) { return floor(index / (numCount * 10)) + 1; } int getMiddleNumber(int index, int numCount, int subNumber) { return floor(floor(index / numCount) / pow(10, numCount - subNumber)); } int getLastNumber(int index, int numCount) { return ((index / numCount) - 1) % 10; } int getNumberFromIndex(int index) { if (index <= 9) return index; int numCount = 1; while (index >= f(numCount)) { index -= f(numCount); numCount++; } switch (int subNumber = index % numCount){ case 0: return getLastNumber(index, numCount); break; case 1: return getFirstNumber(index, numCount); break; default: return getMiddleNumber(index, numCount, subNumber); break; } } void fake() { for (unsigned i=1; i<50; i++) cout << getNumberFromIndex(i); } void real() { auto indexes = getIndexes(); for (unsigned i=0; i<indexes.size(); i++) cout << getNumberFromIndex(indexes.at(i)) << '\n'; } int main() { real(); return 0; }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
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: WRONG ANSWER
input |
---|
1000 615664 916441 627600 279508 ... |
correct output |
---|
1 2 3 2 2 ... |
user output |
---|
2113 712 23 4812 1755 ... Truncated |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 ... |
correct output |
---|
7 2 2 0 9 ... |
user output |
---|
(empty) |