Task: | Käännöt |
Sender: | |
Submission time: | 2015-11-08 21:17:51 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | ACCEPTED | 41 |
#3 | ACCEPTED | 44 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.06 s | 1 | details |
#2 | ACCEPTED | 0.06 s | 1 | details |
#3 | ACCEPTED | 0.05 s | 1 | details |
#4 | ACCEPTED | 0.05 s | 1 | details |
#5 | ACCEPTED | 0.06 s | 1 | details |
#6 | ACCEPTED | 0.06 s | 2 | details |
#7 | ACCEPTED | 0.05 s | 2 | details |
#8 | ACCEPTED | 0.05 s | 2 | details |
#9 | ACCEPTED | 0.06 s | 2 | details |
#10 | ACCEPTED | 0.06 s | 2 | details |
#11 | ACCEPTED | 0.06 s | 3 | details |
#12 | ACCEPTED | 0.06 s | 3 | details |
#13 | ACCEPTED | 0.07 s | 3 | details |
#14 | ACCEPTED | 0.06 s | 3 | details |
#15 | ACCEPTED | 0.06 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:29:22: warning: array subscript has type 'char' [-Wchar-subscripts] inv += asd[s[n-i-1]][i+1]; ^
Code
#include <iostream> #include <algorithm> using namespace std; typedef long long ll; string s; const int Z = 1e9+7; const int MN = 1<<17; ll p10[MN]; ll asd[10][MN]; int main() { cin>>s; int n=s.size(); reverse(s.begin(), s.end()); for(int i=0; i<n; ++i) s[i]-='0'; for(int i=1; i<10; ++i) { for(int j=1; j<=n; ++j) asd[i][j] = (10 * asd[i][j-1] + i)%Z; } p10[0]=1; for(int i=1; i<=n; ++i) p10[i] = 10*p10[i-1]%Z; ll res=0; ll lows=0; ll his=0; ll inv=0; for(int i=0; i<n; ++i) { lows += s[i] * p10[i]; his += s[n-1-i] * p10[n-i-1]; inv += asd[s[n-i-1]][i+1]; lows%=Z; his%=Z; inv%=Z; ll rem = n-i-1; res += lows * rem; res += his * rem; res += inv * p10[n-i-1];; res %= Z; } cout<<res<<'\n'; }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
825864589849478186996872119675... |
correct output |
---|
457966376 |
user output |
---|
457966376 |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
191658935877461356157657491987... |
correct output |
---|
176954270 |
user output |
---|
176954270 |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
348988594526165698179722696175... |
correct output |
---|
338693404 |
user output |
---|
338693404 |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
959161872742625799336943933597... |
correct output |
---|
585928712 |
user output |
---|
585928712 |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
925429363246698689162197257943... |
correct output |
---|
517617697 |
user output |
---|
517617697 |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
972591294933975999938266397628... |
correct output |
---|
667001154 |
user output |
---|
667001154 |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
275688881195265674233697529772... |
correct output |
---|
213272855 |
user output |
---|
213272855 |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
654678934762543351831648468742... |
correct output |
---|
465477034 |
user output |
---|
465477034 |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
852895263384279396767531876338... |
correct output |
---|
225052500 |
user output |
---|
225052500 |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
257723665884149498894428498943... |
correct output |
---|
169577498 |
user output |
---|
169577498 |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
965391619923528543348143963721... |
correct output |
---|
458795777 |
user output |
---|
458795777 |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
934996116481518541954869782274... |
correct output |
---|
38884659 |
user output |
---|
38884659 |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
356521595763548549682719476371... |
correct output |
---|
335143519 |
user output |
---|
335143519 |
Test 14
Group: 3
Verdict: ACCEPTED
input |
---|
691571977153731228387836644955... |
correct output |
---|
504860195 |
user output |
---|
504860195 |
Test 15
Group: 3
Verdict: ACCEPTED
input |
---|
882254176987218851832315176774... |
correct output |
---|
32749477 |
user output |
---|
32749477 |