UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#198360#2287. gameBsnow_trace10065ms1240kbC++112.3kb2023-11-25 10:24:082023-11-25 12:09:55

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const long double pi = acos(-1);
complex<double> a[45],b[45];
int n,m;
inline void FFT(complex<double> *a,int n,int inv){
	if(n == 1)return;
	int mid = n/2;
	complex<double>a1[mid+1],a2[mid+1];
	for(int i = 0;i<=n;i+=2){
		a1[i/2] = a[i];a2[i/2] = a[i+1];
	}FFT(a1,mid,inv),FFT(a2,mid,inv);
	complex<double>w0(1,0),wn(cos(2*pi/n),inv*sin(2*pi/n));
	for(int i =0;i<mid;i++,w0*=wn){
		a[i] = a1[i]+w0*a2[i];
		a[i+n/2] = a1[i]-w0*a2[i];
	}return;
}const int mod = 19260817;
struct Matrix{
	bool ok = 0;
	int len =0,pro = 1;
	int cnt[10][10],tot[10][10];
	void init(){
		memset(cnt,0,sizeof(cnt));memset(tot,0,sizeof(tot));
	}
};
Matrix add(Matrix a,Matrix b){
	if(b.ok == 0){
		return a;
	}Matrix c;c.len = a.len+b.len;c.pro = a.pro*b.pro%mod;c.ok = 1;c.init();
	for(int i = 0;i<=9;i++){
		for(int j = i;j<=9;j++){
			for(int k = j;k<=9;k++){
				for(int l = k;l<=9;l++){
					c.cnt[i][l] = (c.cnt[i][l]+a.cnt[i][j]*b.pro%mod*b.tot[k][l]%mod+b.cnt[k][l]*a.tot[i][j]%mod)%mod;
					c.tot[i][l] = (c.tot[i][l]+a.tot[i][j]*b.tot[k][l])%mod;
				}
			}
		}
	}return c;
}
string s;
signed main(){
	cin >> s;reverse(s.begin(),s.end());
	Matrix pro;pro.init();
	pro.len = 1,pro.pro = 10,pro.ok = 1;for(int i =0;i<=9;i++)pro.cnt[i][i] = i,pro.tot[i][i] = 1;
	Matrix ans;ans.init();
//	for(int i = 0;i<=9;i++){
//		for(int j= 0;j<=9;j++){
//			cout << pro.cnt[i][j] << " ";
//		}cout << endl;
//	}cout << endl;
	for(int i =0;i<s.size();i++){
		s[i]-='0';
	//	cout << "      " << i << " " << s.size() << endl;
		for(int j = 1;j<=s[i];j++)ans = add(pro,ans);
	//	for(int j =0;j<=9;j++){
	//		for(int k = 0;k<=9;k++){
	//			cout << ans.cnt[j][k] << " ";
	//		}cout << endl;
		//}cout <<endl << endl;
		Matrix tt = pro;
		pro = add(pro,pro),pro= add(pro,pro),pro = add(pro,pro);pro = add(tt,pro);pro = add(tt,pro);
	//	cout << 111 << endl;
	}int res = 0;
	for(int i = 0;i<=9;i++)for(int j = i;j<=9;j++)res = (res+ans.cnt[i][j])%mod;
	cout << res << endl;
	return 0;
}/*
  
 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
 */

Details

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 0ms
memory: 1232kb

input:

1

output:

45

result:

ok single line: '45'

Test #2:

score: 0
Accepted
time: 0ms
memory: 1228kb

input:

5

output:

17811218

result:

ok single line: '17811218'

Test #3:

score: 0
Accepted
time: 0ms
memory: 1228kb

input:

7

output:

17964082

result:

ok single line: '17964082'

Test #4:

score: 0
Accepted
time: 0ms
memory: 1232kb

input:

8

output:

1381686

result:

ok single line: '1381686'

Subtask #2:

score: 30
Accepted

Test #5:

score: 30
Accepted
time: 1ms
memory: 1232kb

input:

1000000

output:

16408526

result:

ok single line: '16408526'

Test #6:

score: 0
Accepted
time: 0ms
memory: 1236kb

input:

412831

output:

2674077

result:

ok single line: '2674077'

Test #7:

score: 0
Accepted
time: 0ms
memory: 1232kb

input:

912536

output:

14888499

result:

ok single line: '14888499'

Test #8:

score: 0
Accepted
time: 0ms
memory: 1236kb

input:

903333

output:

15140884

result:

ok single line: '15140884'

Test #9:

score: 0
Accepted
time: 0ms
memory: 1232kb

input:

233333

output:

10226505

result:

ok single line: '10226505'

Subtask #3:

score: 30
Accepted

Test #10:

score: 30
Accepted
time: 0ms
memory: 1236kb

input:

10000000

output:

1016402

result:

ok single line: '1016402'

Test #11:

score: 0
Accepted
time: 0ms
memory: 1236kb

input:

9984423

output:

2091766

result:

ok single line: '2091766'

Test #12:

score: 0
Accepted
time: 0ms
memory: 1236kb

input:

8902333

output:

470106

result:

ok single line: '470106'

Subtask #4:

score: 20
Accepted

Test #13:

score: 20
Accepted
time: 13ms
memory: 1240kb

input:

6174094882455171152761423221685761892795431233411387427793198650286024865090061389344606618496378829...

output:

312316

result:

ok single line: '312316'

Test #14:

score: 0
Accepted
time: 13ms
memory: 1236kb

input:

7950133213935099898599641969335465913738684180913038150315027808878822533688086430963642514379083930...

output:

495255

result:

ok single line: '495255'

Test #15:

score: 0
Accepted
time: 14ms
memory: 1236kb

input:

8285592102183214352312947639978238302973931228292134269415975170602272610947686062169970590448176525...

output:

5847863

result:

ok single line: '5847863'

Test #16:

score: 0
Accepted
time: 12ms
memory: 1236kb

input:

4836770525732753891758123236387000695921845132248562145323089039419111557010946099052593715936883515...

output:

7728339

result:

ok single line: '7728339'

Test #17:

score: 0
Accepted
time: 12ms
memory: 1240kb

input:

1754943949129825178393746785202107105314687112215787969343231363239364718973149805478237258128540220...

output:

12349203

result:

ok single line: '12349203'

Extra Test:

score: 0
Extra Test Passed