結果

問題 No.372 It's automatic
ユーザー FF256grhyFF256grhy
提出日時 2016-05-14 19:03:27
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 522 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 26,452 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-28 12:49:53
合計ジャッジ時間 16,722 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1,216 ms
4,380 KB
testcase_05 AC 1,217 ms
4,376 KB
testcase_06 AC 1,217 ms
4,380 KB
testcase_07 AC 1,229 ms
4,380 KB
testcase_08 AC 1,226 ms
4,376 KB
testcase_09 AC 1,216 ms
4,376 KB
testcase_10 AC 1,216 ms
4,380 KB
testcase_11 AC 1,206 ms
4,380 KB
testcase_12 AC 1,225 ms
4,380 KB
testcase_13 AC 1,211 ms
4,380 KB
testcase_14 AC 1,224 ms
4,380 KB
testcase_15 AC 1,225 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 62 ms
4,380 KB
testcase_22 AC 63 ms
4,376 KB
testcase_23 AC 63 ms
4,380 KB
testcase_24 AC 63 ms
4,380 KB
testcase_25 AC 63 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:25: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  printf("%d\n", (dp[b][0] - 1 + zero) % MOD);
                  ~~~~~~~^

ソースコード

diff #

#include <stdio.h>

#define MOD 1000000007

char s[10001];
int m, dp[2][20000];

int main() {
	scanf("%s%d",s, &m);
	
	dp[0][0] = 1;
	
	int i = 0, a, b, zero = 0;
	while(s[i] != '\0') {
		a = i % 2;
		b = (i + 1) % 2;
		int d = s[i] - '0';
		zero += (d == 0);
		for(int j = 0; j < m; j++) {
			dp[b][j] = dp[a][j];
		}
		for(int j = 0; j < m; j++) {
			int k = (10 * j + d) % m;
			dp[b][k] += dp[a][j] - (d == 0 && j == 0);
			dp[b][k] %= MOD;
		}
		i++;
	}
	
	printf("%d\n", (dp[b][0] - 1 + zero) % MOD);
	
	return 0;
}
0