結果

問題 No.129 お年玉(2)
ユーザー IL_mstaIL_msta
提出日時 2015-07-03 06:40:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 559 ms / 5,000 ms
コード長 1,146 bytes
コンパイル時間 982 ms
コンパイル使用メモリ 83,828 KB
実行使用メモリ 166,004 KB
最終ジャッジ日時 2023-08-18 17:20:28
合計ジャッジ時間 11,927 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
18,672 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 186 ms
68,012 KB
testcase_06 AC 297 ms
113,772 KB
testcase_07 AC 425 ms
142,356 KB
testcase_08 AC 189 ms
68,040 KB
testcase_09 AC 393 ms
133,600 KB
testcase_10 AC 463 ms
146,780 KB
testcase_11 AC 250 ms
93,344 KB
testcase_12 AC 156 ms
61,484 KB
testcase_13 AC 120 ms
54,984 KB
testcase_14 AC 354 ms
121,672 KB
testcase_15 AC 269 ms
101,516 KB
testcase_16 AC 265 ms
103,540 KB
testcase_17 AC 442 ms
137,168 KB
testcase_18 AC 410 ms
133,284 KB
testcase_19 AC 325 ms
103,056 KB
testcase_20 AC 349 ms
125,588 KB
testcase_21 AC 559 ms
166,004 KB
testcase_22 AC 292 ms
103,468 KB
testcase_23 AC 478 ms
151,464 KB
testcase_24 AC 199 ms
73,476 KB
testcase_25 AC 225 ms
88,508 KB
testcase_26 AC 287 ms
97,464 KB
testcase_27 AC 289 ms
97,992 KB
testcase_28 AC 480 ms
158,464 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 4 ms
5,508 KB
testcase_35 AC 5 ms
6,352 KB
testcase_36 AC 7 ms
7,356 KB
testcase_37 AC 7 ms
7,672 KB
testcase_38 AC 56 ms
29,272 KB
testcase_39 AC 92 ms
40,992 KB
testcase_40 AC 270 ms
92,780 KB
testcase_41 AC 153 ms
61,736 KB
testcase_42 AC 66 ms
33,180 KB
testcase_43 AC 52 ms
27,176 KB
testcase_44 AC 441 ms
129,996 KB
testcase_45 AC 43 ms
22,100 KB
testcase_46 AC 72 ms
33,912 KB
testcase_47 AC 542 ms
159,184 KB
testcase_48 AC 223 ms
77,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const LL mod = (LL)1e9;
const int maxC = 10000;
LL c[maxC][maxC/2];

LL ccc(LL n,LL k){
	LL ans;
	LL kk = min(k,n-k);
	if(n<maxC && kk < maxC && c[n][kk] != 0){
		ans = c[n][kk];
	}
	else if(kk ==0 ){
		if(n<maxC){
			c[n][kk] = 1;
		}
		ans = 1;
	}else if( kk==1){
		if(n<maxC){
			c[n][kk] = n%mod;
		}
		ans = n%mod;
	}
	else{
		ans = (ccc(n-1,kk-1)%mod+ccc(n-1,kk)%mod)%mod;
		if(n<maxC && kk < maxC){
			c[n][kk] = ans;
		}
	}

	return ans;
}
int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
    
	LL N,M;
	cin>>N>>M;
	LL ama = (N%(M*1000))/1000;
	//rep(i,maxC)rep(j,maxC)c[i][j]=-1;
	//N C ama
	P(ccc(M,ama));
    return 0;
}
0