結果

問題 No.372 It's automatic
ユーザー akakimidoriakakimidori
提出日時 2018-08-30 01:12:12
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 26,032 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-10-11 20:54:11
合計ジャッジ時間 17,760 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 0 ms
4,352 KB
testcase_02 AC 0 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0