CSES - Putka Open 2015 – 5/6 - Results
Submission details
Task:Käännöt
Sender:
Submission time:2015-11-08 04:28:19 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.04 s1details
#20.05 s1details
#30.06 s1details
#40.05 s1details
#50.05 s1details
#60.05 s2details
#70.04 s2details
#80.05 s2details
#90.06 s2details
#100.05 s2details
#110.06 s3details
#120.06 s3details
#130.07 s3details
#140.06 s3details
#150.06 s3details

Code

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

const uint64_t MOD=1000*1000*1000+7;

uint64_t pairs(uint64_t a){return a?((a-1)*(a-2)/2+a-1)%MOD:0;}

int main(){
  std::string s;std::cin>>s;
  std::reverse(s.begin(),s.end());
  uint64_t n=s.size();

  std::vector<uint64_t>pow10(n);pow10[0]=1;
  for(unsigned i=1;i<n;++i)pow10[i]=(pow10[i-1]*10)%MOD;

  auto pow10_range=pow10;
  for(unsigned i=1;i<n;++i)(pow10_range[i]+=pow10_range[i-1])%=MOD;

  std::vector<uint64_t>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;

  uint64_t 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;
  }
  std::cout<<sum<<'\n';
}

Test details

Test 1

Group: 1

Verdict:

input
825864589849478186996872119675...

correct output
457966376

user output
188285723

Test 2

Group: 1

Verdict:

input
191658935877461356157657491987...

correct output
176954270

user output
454001766

Test 3

Group: 1

Verdict:

input
348988594526165698179722696175...

correct output
338693404

user output
495502037

Test 4

Group: 1

Verdict:

input
959161872742625799336943933597...

correct output
585928712

user output
455672829

Test 5

Group: 1

Verdict:

input
925429363246698689162197257943...

correct output
517617697

user output
125560537

Test 6

Group: 2

Verdict:

input
972591294933975999938266397628...

correct output
667001154

user output
180539176

Test 7

Group: 2

Verdict:

input
275688881195265674233697529772...

correct output
213272855

user output
103975684

Test 8

Group: 2

Verdict:

input
654678934762543351831648468742...

correct output
465477034

user output
96587385

Test 9

Group: 2

Verdict:

input
852895263384279396767531876338...

correct output
225052500

user output
369604166

Test 10

Group: 2

Verdict:

input
257723665884149498894428498943...

correct output
169577498

user output
685375306

Test 11

Group: 3

Verdict:

input
965391619923528543348143963721...

correct output
458795777

user output
746017586

Test 12

Group: 3

Verdict:

input
934996116481518541954869782274...

correct output
38884659

user output
308448958

Test 13

Group: 3

Verdict:

input
356521595763548549682719476371...

correct output
335143519

user output
931596405

Test 14

Group: 3

Verdict:

input
691571977153731228387836644955...

correct output
504860195

user output
469667379

Test 15

Group: 3

Verdict:

input
882254176987218851832315176774...

correct output
32749477

user output
913349181