| Task: | Käännöt |
| Sender: | |
| Submission time: | 2015-11-08 05:42:20 +0200 |
| 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.15 s | 1 | details |
| #2 | RUNTIME ERROR | 0.15 s | 1 | details |
| #3 | RUNTIME ERROR | 0.16 s | 1 | details |
| #4 | RUNTIME ERROR | 0.14 s | 1 | details |
| #5 | RUNTIME ERROR | 0.15 s | 1 | details |
| #6 | RUNTIME ERROR | 0.14 s | 2 | details |
| #7 | RUNTIME ERROR | 0.13 s | 2 | details |
| #8 | RUNTIME ERROR | 0.14 s | 2 | details |
| #9 | RUNTIME ERROR | 0.13 s | 2 | details |
| #10 | RUNTIME ERROR | 0.13 s | 2 | details |
| #11 | RUNTIME ERROR | 0.15 s | 3 | details |
| #12 | RUNTIME ERROR | 0.14 s | 3 | details |
| #13 | RUNTIME ERROR | 0.14 s | 3 | details |
| #14 | RUNTIME ERROR | 0.14 s | 3 | details |
| #15 | RUNTIME ERROR | 0.15 s | 3 | details |
Code
#include <stdint.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
const unsigned long long MOD=1000*1000*1000+7;
unsigned long long pairs(unsigned long long a){return a?((a-1)*(a-2)/2+a-1):0;}
int main(){
std::ios_base::sync_with_stdio(false);
std::string s;
unsigned long long n = 0;
for (char c; std::cin >> c;)
if (c>='1'&&c<='9')s+=c,++n;
if (n>5) throw n;
std::reverse(s.begin(),s.end());
std::vector<unsigned long long>pow10(n);pow10[0]=1;
for(unsigned i=1;i<n;++i)pow10[i]=(pow10[i-1]*10)%MOD;
unsigned long long sum1=0;
for(unsigned i=0;i<n;++i){
for(unsigned j=i;j<n;++j){
std::reverse(&s[i],&s[j+1]);
for(unsigned k=0;k<n;++k)
(sum1+=(s[k]-'0')*pow10[k])%=MOD;
std::reverse(&s[i],&s[j+1]);
}
}
auto pow10_range=pow10;
for(unsigned i=1;i<n;++i)(pow10_range[i]+=pow10_range[i-1])%=MOD;
std::vector<unsigned long long>T(n);
T[n-1]=T[0]=pow10_range[n-1];
for(unsigned i=1;i<(n+1)/2;++i)
T[n-i-1]=T[i]=(T[i-1]+pow10_range[n-i-1]-pow10_range[i-1])%MOD;
unsigned long long sum=0;
for(unsigned k=0;k<n;++k){
sum+=(s[k]-'0')*pow10[k]*(pairs(k+1)+pairs(n-k));
sum%=MOD;
sum+=(s[k]-'0')*T[k];
sum%=MOD;
}
if (n == 3) std::cout << sum1 << '\n';
else std::cout << sum1 << '\n';
}
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 825864589849478186996872119675... |
| correct output |
|---|
| 457966376 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 2
Group: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 191658935877461356157657491987... |
| correct output |
|---|
| 176954270 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 3
Group: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 348988594526165698179722696175... |
| correct output |
|---|
| 338693404 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 4
Group: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 959161872742625799336943933597... |
| correct output |
|---|
| 585928712 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 5
Group: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 925429363246698689162197257943... |
| correct output |
|---|
| 517617697 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 6
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 972591294933975999938266397628... |
| correct output |
|---|
| 667001154 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 7
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 275688881195265674233697529772... |
| correct output |
|---|
| 213272855 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 8
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 654678934762543351831648468742... |
| correct output |
|---|
| 465477034 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 9
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 852895263384279396767531876338... |
| correct output |
|---|
| 225052500 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 10
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 257723665884149498894428498943... |
| correct output |
|---|
| 169577498 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 11
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 965391619923528543348143963721... |
| correct output |
|---|
| 458795777 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 12
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 934996116481518541954869782274... |
| correct output |
|---|
| 38884659 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 13
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 356521595763548549682719476371... |
| correct output |
|---|
| 335143519 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 14
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 691571977153731228387836644955... |
| correct output |
|---|
| 504860195 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
Test 15
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 882254176987218851832315176774... |
| correct output |
|---|
| 32749477 |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'unsigned long long'
