結果

問題 No.372 It's automatic
ユーザー akakimidoriakakimidori
提出日時 2018-08-30 03:34:04
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 964 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 30,080 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-11 20:56:07
合計ジャッジ時間 5,317 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef unsigned long long int int64;

void run(void){
  char *s=(char *)malloc(sizeof(char)*(10000+1));
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  int m;
  scanf("%d",&m);
  int64 *now=(int64 *)calloc(m,sizeof(int64));
  int64 *next=(int64 *)calloc(m,sizeof(int64));
  int cnt=0;
  const int mod=1000000007;
  const int f=32;
  int k=0;
  while(k<n){
    int kk;
    int up=(f<=n-k?f:n-k);
    for(kk=0;kk<up;kk++){
      int d=s[k+kk]-'0';
      memcpy(next,now,m*sizeof(int64));
      int i,j;
      j=0;
      while(j<m){
        for(i=(10*j+d)%m;j<m && i<m;i+=10,j++){
          next[i]+=now[j];
        }
      }
      if(d==0){
        cnt++;
      } else {
        next[d%m]++;
      }
      int64 *swap=now;
      now=next;
      next=swap;
    }
    k+=kk;
    int i;
    for(i=0;i<m;i++) now[i]%=mod;
  }
  printf("%lld\n",(now[0]+cnt)%mod);
}

int main(void){
  run();
  return 0;
}
0