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

Code

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;

const ll mod=1e9+7;
const ll ik=700000005;
ll dd[101010];
ll dd2[101010];
ll vv1[101010];
ll vv2[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	if (n==1){
		cout<<s<<endl;
		return 0;
	}
	ll e=1;
	for (int i=n-1;i>=0;i--){
		vv1[i]=(e*(ll)(s[i]-'0'))%mod;
		vv2[n-i-1]=(e*(ll)(s[i]-'0'))%mod;
		e*=10ll;
		e%=mod;
	}
	ll k=1;
	ll k2=1;
	int p1=(n-1)/2;
	int p2=(n)/2;
	for (int i=-1;i<(int)n-1;i++){
		//cout<<p1<<" "<<p2<<endl;
		dd[i+1]+=k;
		dd[i+1]%=mod;
		dd[p1+1]+=mod-k;
		dd[p1+1]%=mod;
		dd[p2+1]+=mod-k;
		dd[p2+1]%=mod;
		if (i>-1){
			//cout<<"k2 "<<k2<<endl;
			dd2[i+1]+=k2;
			dd2[i+1]%=mod;
			dd2[p1+1]+=mod-k2;
			dd2[p1+1]%=mod;
			dd2[p2+1]+=mod-k2;
			dd2[p2+1]%=mod;
		}
		k*=10ll;
		k%=mod;
		k2*=ik;
		k2%=mod;
		if ((n+i)%2==0){
			p2++;
		}
		else{
			p1++;
		}
	}
	//cout<<(ik*vv2[1])%mod<<" "<<ik<<endl;
	ll d=dd[0];
	ll d2=dd2[0];
	ll kk=0;
	ll kk2=0;
	ll v=0;
	for (int i=0;i<n;i++){
		kk+=d;
		kk%=mod;
		kk2+=d2;
		kk2%=mod;
		v+=kk*vv1[i];
		//cout<<"kk2 "<<kk2<<" "<<vv2[i]<<" "<<(kk2*vv2[i])%mod<<endl;
		v+=kk2*vv2[i];
		v%=mod;
		//cout<<kk<<" "<<vv1[i]<<endl;
		d+=dd[i+1];
		d%=mod;
		d2+=dd2[i+1];
		d2%=mod;
	}
	//cout<<v<<endl;
	for (int i=0;i<n;i++){
		v+=((ll)i*(ll)(i+1)/(ll)2)*vv1[i];
		v%=mod;
		v+=((ll)(n-i-1)*(ll)(n-i)/(ll)2)*vv1[i];
		v%=mod;
	}
	cout<<v<<endl;
}

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