Task: | Numerot |
Sender: | Sisuaski |
Submission time: | 2020-10-17 09:10:53 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.07 s | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream> #include <map> using namespace std; typedef unsigned long long ull; typedef pair<ull, int> P; map<P, P> M; P f(unsigned k, ull n) { if (n==0 && k==0) return {0, 0}; if (n<=k) return {1, k-n}; if (n<10) return {1, 0}; auto& dp = M[P(n,k)]; if (dp.first > 0) return dp; ull g=1; for(; g<=n/10; g*=10); ull res=0; while(1) { unsigned a = n/g; P p = f(max(k,a), n%g); res += p.first; if (a==0) return dp = {res, p.second}; n = a*g - p.second; if (p.second == 0) { n -= a; res++; } } } int main() { int t;cin>>t; while(t--){ ull x;cin>>x; ull low=x-1, hi=9*x; while(hi-low>1) { ull mid = low+(hi-low)/2; if (f(0,mid).first < x) low=mid; else hi=mid; } cout<<hi<<'\n'; } }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1000 1 2 3 4 ... |
correct output |
---|
1 10 11 20 22 ... |
user output |
---|
1 10 11 20 22 ... Truncated |
Test 2
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1000 224995 413660 249827 2125 ... |
correct output |
---|
1731724 3216040 1940719 14585 532612 ... |
user output |
---|
1563211 2892164 1736557 13771 485672 ... Truncated |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 627887018110416188 785474884983906653 653772166720939773 784335285960673683 ... |
correct output |
---|
5530371754830260284 6918696171534226533 5757755627065159149 6908439780325129803 3223801064342340738 ... |
user output |
---|
(empty) |