結果

問題 No.129 お年玉(2)
ユーザー tefunamu
提出日時 2015-01-16 23:51:37
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 570 bytes
コンパイル時間 952 ms
コンパイル使用メモリ 20,656 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-22 12:51:36
合計ジャッジ時間 1,532 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 42
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:13:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%ld",&N);
      |     ^~~~~~~~~~~~~~~
main.c:14:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%d",&M);
      |     ^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

const unsigned long divide = 100000000;
unsigned long combi(int n,int r);


int main(int argc, const char * argv[]) {
    
    unsigned long N;
    int M;
    
    
    scanf("%ld",&N);
    scanf("%d",&M);
    
    unsigned long amari = (N - ((N/1000/M*1000) * M)) / 1000;
    
    
    printf("%ld\n",combi(M,(int)amari));

    
    return 0;
    
}

unsigned long combi(int n,int r){
    int i;
    unsigned long p=1;
    
    for (i=1;i<=r;i++){
        p=p*(n-i+1)/i;
        if(p>= divide){
            p%=divide;
        }
    }
    return p;
}
0