CSES - Putka Open 2015 – 5/6 - Results
Submission details
Task:Käännöt
Sender:
Submission time:2015-11-07 10:21:37 +0200
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED15
#2ACCEPTED41
#3ACCEPTED44
Test results
testverdicttimegroup
#1ACCEPTED0.04 s1details
#2ACCEPTED0.06 s1details
#3ACCEPTED0.05 s1details
#4ACCEPTED0.06 s1details
#5ACCEPTED0.05 s1details
#6ACCEPTED0.06 s2details
#7ACCEPTED0.06 s2details
#8ACCEPTED0.06 s2details
#9ACCEPTED0.06 s2details
#10ACCEPTED0.05 s2details
#11ACCEPTED0.39 s3details
#12ACCEPTED0.40 s3details
#13ACCEPTED0.40 s3details
#14ACCEPTED0.40 s3details
#15ACCEPTED0.40 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:31:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int64_t i=0;i<luku.size();i++) {
                    ^

Code

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<algorithm>
#include<cmath>
#include<utility>

using namespace std;

int64_t power_mod(int64_t a, int64_t k, int64_t m) {
  if(k == 0) return 1;
  int64_t res=power_mod(a, k/2, m);
  if(k%2 == 0) return res*res%m;
  return a*res%m*res%m;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  string luku;
  cin >> luku;

  int64_t n=luku.size()-1;
  int64_t total=0;
  int64_t tenpow=1;
  const int64_t MOD=1000000007;
  for(int64_t i=0;i<luku.size();i++) {
    int64_t a = luku[luku.size()-1-i]-'0';
    total+=((n-i)*(n-i-1)/2 + n - i + i*(i-1)/2 + i)%MOD*a*tenpow;
    total%=MOD;
    if(2*i <= n) {
      total+=a*(power_mod(10,i+1,MOD)*(9*i+8)+1)%MOD*power_mod(81,MOD-2,MOD)%MOD;
      total%=MOD;
      /*for(int64_t u=i;u<=2*i;u++) {
        total+=a*(u-i+1)%MOD*power_mod(10, u-i, MOD);
        total%=MOD;
      }*/
      total+=a*(10*(-power_mod(10,i,MOD) + power_mod(10,n-i,MOD))%MOD*(i+1)%MOD*power_mod(9,MOD-2,MOD))%MOD;
      total%=MOD;
      /*for(int64_t u=2*i+1;u<=n;u++) {
        total+=a*(i+1)%MOD*power_mod(10, u-i, MOD);
        total%=MOD;
      }*/
      total+=a*(power_mod(10,(i + 1),MOD) - 9*i - 10)%MOD*power_mod(10,(-i + n + 1),MOD)%MOD*power_mod(81,MOD-2,MOD)%MOD;
      total%=MOD;
      /*for(int64_t u=n+1;u<=n+i;u++) {
        total+=a*(i-u+n+1)%MOD*power_mod(10, u-i, MOD);
        total%=MOD;
      }*/
    } else {
      total+=a*(power_mod(10,(n-i+1),MOD)*(9*(n-i)+8) + 1)%MOD*power_mod(81,MOD-2,MOD)%MOD;
      total%=MOD;
      /*for(int64_t u=i;u<=n;u++) {
        total+=a*(u-i+1)%MOD*power_mod(10, u-i, MOD);
        total%=MOD;
      }*/
      total+=a*(power_mod(10,i,MOD) - power_mod(10,n-i,MOD))%MOD*10*(n-i+1)%MOD*power_mod(9,MOD-2,MOD)%MOD;
      total%=MOD;
      /*for(int64_t u=n+1;u<=2*i;u++) {
        total+=a*(n-i+1)%MOD*power_mod(10, u-i, MOD);
        total%=MOD;
      }*/
      total+=a*(power_mod(10,n+2,MOD)-9*power_mod(10,i+1,MOD)*(n-i) - power_mod(10,(i + 2),MOD))%MOD*power_mod(81,MOD-2,MOD)%MOD;
      total%=MOD;
      /*for(int64_t u=2*i+1;u<=n+i;u++) {
        total+=a*(i-u+n+1)%MOD*power_mod(10, u-i, MOD);
        total%=MOD;
      }*/
    }
    tenpow*=10;
    tenpow%=MOD;
  }

  cout << total << endl;

  return 0;
}

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