結果

問題 No.129 お年玉(2)
ユーザー akakimidori
提出日時 2017-06-10 22:09:58
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 236 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 1,270 ms
コンパイル使用メモリ 21,888 KB
実行使用メモリ 234,752 KB
最終ジャッジ日時 2024-11-28 00:52:04
合計ジャッジ時間 6,837 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:7:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   scanf("%lld%d",&n,&m);
      |   ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

void run(void){
  long long int n;
  int m;
  scanf("%lld%d",&n,&m);
  int t=(int)(n%(1000*m))/1000;

  int *comb=(int *)calloc((m+1)*(m+1),sizeof(int));
  comb[0]=1;
  const int mod=1000000000;
  int i,j;
  for(i=1;i<=m;i++){
    comb[i*(m+1)]=1;
    for(j=1;j<=i;j++){
      comb[i*(m+1)+j]=(comb[(i-1)*(m+1)+j-1]+comb[(i-1)*(m+1)+j])%mod;
    }
  }
  printf("%d\n",comb[m*(m+1)+t]);
  return;
}

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