結果

問題 No.129 お年玉(2)
ユーザー koyumeishi
提出日時 2015-01-16 23:49:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 774 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 77,448 KB
実行使用メモリ 784,896 KB
最終ジャッジ日時 2024-06-22 12:49:32
合計ジャッジ時間 16,649 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41 MLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

#define MOD 1000000000

int main(){
	long long n,m;
	cin >> n >> m;
	n -= ((n/m)/1000) * 1000 * m;

	n /= 1000;
	//cout << n << endl;

	//dp[i][j] := 使った千円札の数がi枚で、j番目の袋までに入れた場合の組み合わせ
	vector<vector<long long>> dp(n+1, vector<long long>(m+1, 0));
	dp[0][0] = 1;
	for(int i=0; i<=n; i++){
		for(int j=0; j<m; j++){
			dp[i][j+1] += dp[i][j];
			dp[i][j+1] %= MOD;
			if(i+1 <= n){
				dp[i+1][j+1] += dp[i][j];
				dp[i+1][j+1] %= MOD;
			}
		}
	}

	long long ans = dp[n][m] % MOD;
	cout << ans << endl;
	return 0;
}
0