結果

問題 No.129 お年玉(2)
ユーザー IL_mstaIL_msta
提出日時 2015-07-03 06:27:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,041 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 83,336 KB
実行使用メモリ 15,536 KB
最終ジャッジ日時 2023-09-22 05:55:36
合計ジャッジ時間 13,206 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

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;
LL c[1000][1000];

LL ccc(LL n,LL k){
	LL kk = min(k,n-k);
	if(kk ==0 ){
		return 1;
	}else if( kk==1){
		return n%mod;
	}else if(n<1000 && kk < 1000 && c[n][kk] != -1){
		return c[n][kk];
	}
	////////
	LL ans;
	ans = (ccc(n-1,kk-1)%mod+ccc(n-1,kk)%mod)%mod;
	if(n<1000 && kk < 1000){
		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,1000)rep(j,1000)c[i][j]=-1;
	//N C ama
	P(ccc(M,ama));
    return 0;
}
0