結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー publflpublfl
提出日時 2021-03-05 21:41:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 3,000 ms
コード長 883 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 34,176 KB
実行使用メモリ 13,144 KB
最終ジャッジ日時 2024-04-16 09:06:16
合計ジャッジ時間 1,478 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,948 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 3 ms
6,944 KB
testcase_32 AC 6 ms
6,940 KB
testcase_33 AC 11 ms
10,288 KB
testcase_34 AC 18 ms
12,808 KB
testcase_35 AC 17 ms
12,980 KB
testcase_36 AC 18 ms
13,040 KB
testcase_37 AC 21 ms
13,120 KB
testcase_38 AC 18 ms
13,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#define MOD 1000000007

int gcd(int a, int b)
{
	return a?gcd(b%a,a):b;
}

int a;
char x[10010];
int y[10010];
long long int check[10010][110];
long long int func(int s, int t)
{
	if(s>a)
	{
		if(t==100) return 1;
		else return 0;
	}
	if(check[s][t]!=-1) return check[s][t];
	
	long long int ans = 0;
	for(int i=1;i<=9;i++) ans += func(s+1,gcd(100,t*i)), ans %= MOD;
	return check[s][t] = ans;
}

int main()
{
	scanf("%s",x+1);
	a = strlen(x+1);
	for(int i=1;i<=a;i++) for(int j=0;j<=100;j++) check[i][j] = -1;
	
	long long int ans = 0;
	for(int i=2;i<=a;i++) ans += func(i,1), ans %= MOD;
	
	for(int i=1;i<=a;i++) y[i] = (x[i]-'0');
	long long int t = 1;
	for(int i=1;i<=a;i++)
	{
		if(y[i]==0) goto u;
		for(int j=1;j<y[i];j++) ans += func(i+1,gcd(100,t*j)), ans%= MOD;
		t = gcd(100,t*y[i]);
	}
	if(t==100) ans++;
	u:;
	printf("%lld",ans);
}
0