結果

問題 No.129 お年玉(2)
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-14 22:32:57
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 318 ms / 5,000 ms
コード長 814 bytes
コンパイル時間 1,345 ms
コンパイル使用メモリ 26,008 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 17:23:51
合計ジャッジ時間 6,268 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 44 ms
4,380 KB
testcase_06 AC 200 ms
4,376 KB
testcase_07 AC 208 ms
4,376 KB
testcase_08 AC 30 ms
4,376 KB
testcase_09 AC 175 ms
4,376 KB
testcase_10 AC 180 ms
4,376 KB
testcase_11 AC 163 ms
4,380 KB
testcase_12 AC 18 ms
4,376 KB
testcase_13 AC 12 ms
4,380 KB
testcase_14 AC 201 ms
4,376 KB
testcase_15 AC 170 ms
4,376 KB
testcase_16 AC 221 ms
4,380 KB
testcase_17 AC 147 ms
4,376 KB
testcase_18 AC 157 ms
4,380 KB
testcase_19 AC 59 ms
4,384 KB
testcase_20 AC 258 ms
4,380 KB
testcase_21 AC 194 ms
4,380 KB
testcase_22 AC 154 ms
4,380 KB
testcase_23 AC 205 ms
4,376 KB
testcase_24 AC 24 ms
4,384 KB
testcase_25 AC 177 ms
4,376 KB
testcase_26 AC 86 ms
4,376 KB
testcase_27 AC 101 ms
4,380 KB
testcase_28 AC 318 ms
4,384 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 0 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 0 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 32 ms
4,380 KB
testcase_39 AC 32 ms
4,380 KB
testcase_40 AC 91 ms
4,380 KB
testcase_41 AC 81 ms
4,380 KB
testcase_42 AC 30 ms
4,380 KB
testcase_43 AC 10 ms
4,380 KB
testcase_44 AC 89 ms
4,376 KB
testcase_45 AC 18 ms
4,376 KB
testcase_46 AC 12 ms
4,376 KB
testcase_47 AC 161 ms
4,376 KB
testcase_48 AC 40 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

long long int sum,n,m,r;

int gcd( int a, int b){
	if(b == 0){
		return a;
	}
	
	if(a > b){
		return gcd(b,a%b);
	}else{
		return gcd(a,b%a);
	}
}
int C(int n, int r){
	int i, j, tr;
	int tmp[10010]={0};
	sum = 1;
	
	if( n < r ){return 0;}
	
	for(i=0;i<10010;i++){
		tmp[i] = 1;
	}
	
	for(i=n;i>1;i--){
		if( r == i ){break;}
		if( (n-r) == i ){break;}
		tmp[i] = i;
	}
	tr = n-i;
	
	for(i=2;i<=tr;i++){
		int ti=i;
		for(j=2;j<=n;j++){
			int g = gcd(tmp[j], ti);
			if( g != 1){
				tmp[j] /= g;
				ti /= g;
			}
			if(ti == 1){
				break;
			}
		}
	}
	
	
	for(i=1;i<=n;i++){
		if(tmp[i] != 0){
			sum = (sum*tmp[i])% 1000000000;
		}
	}
	return (int)(sum);
}

int main(void){
	
	scanf("%lld", &n);
	scanf("%lld", &m);
	
	r = (n / 1000) % m;
	
	printf("%d\n", C((int)m,(int)r));

	return 0;
}
0