結果
問題 |
No.372 It's automatic
|
ユーザー |
![]() |
提出日時 | 2018-08-30 01:12:12 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 812 bytes |
コンパイル時間 | 1,061 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-13 19:44:42 |
合計ジャッジ時間 | 13,085 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 WA * 22 |
コンパイルメッセージ
main.c: In function ‘run’: main.c:13:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%s",s); | ^~~~~~~~~~~~~ main.c:15:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d",&m); | ^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> #include<math.h> typedef long long int int64; #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(a) ((a)>(0)?(a):-(a)) void run(void){ char *s=(char *)malloc(sizeof(char)*(10000+1)); scanf("%s",s); int m; scanf("%d",&m); int *now=(int *)calloc(m,sizeof(int)); int *next=(int *)calloc(m,sizeof(int)); int cnt=0; const int mod=1000000007; int n; for(n=0;s[n]!='\0';n++){ int d=s[n]-'0'; int j; for(j=0;j<m;j++) next[j]=0; for(j=0;j<m;j++){ next[j]=(next[j]+now[j])%mod; next[(10*j+d)%m]=(next[(10*m+d)%m]+now[j])%mod; } if(d==0) cnt++; else next[d%m]++; int *swap=now; now=next; next=swap; } printf("%d\n",(now[0]+cnt)%mod); } int main(void){ run(); return 0; }