Submission #3829722


Source Code Expand

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

void run(void){
  int d;
  scanf("%d",&d);
  char *s=(char *)calloc(10000+1,sizeof(char));
  scanf("%s",s);
  const int mod=1000000007;
  int sup=0;
  int *now=(int *)calloc(d,sizeof(int));
  int *next=(int *)calloc(d,sizeof(int));
  int i,j,k;
  for(i=0;s[i]!='\0';i++){
    memset(next,0,sizeof(int)*d);
    for(j=0;j<d;j++){
      for(k=0;k<=9;k++){
	int x=(j+k)%d;
	next[x]=(next[x]+now[j])%mod;
      }
    }
    for(j=0;j<s[i]-'0';j++){
      int x=(sup+j)%d;
      next[x]=(next[x]+1)%mod;
    }
    sup=(sup+s[i]-'0')%d;
    int *swap=now;
    now=next;
    next=swap;
  }
  printf("%d\n",(now[0]-1+(sup==0?1:0)+mod)%mod);
}

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

Submission Info

Submission Time
Task E - 数
User sansen
Language C (GCC 5.4.1)
Score 4
Code Size 768 Byte
Status AC
Exec Time 46 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘run’:
./Main.c:7:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&d);
   ^
./Main.c:9:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",s);
   ^

Judge Result

Set Name All
Score / Max Score 4 / 4
Status
AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 1 ms 128 KB
01 AC 28 ms 128 KB
02 AC 46 ms 128 KB
90 AC 1 ms 128 KB
91 AC 1 ms 128 KB