結果

問題 No.129 お年玉(2)
ユーザー nksk38
提出日時 2017-07-16 15:25:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 940 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 83,760 KB
実行使用メモリ 734,272 KB
最終ジャッジ日時 2025-03-20 02:47:11
合計ジャッジ時間 21,805 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 MLE * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

ll mod = (ll)1e9;


ll C[10010][10010];

void comb_table(ll N) {
	for (ll i = 0; i <= N; i++) {
		for (ll j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
				C[i][j] %= mod;
			}
		}
	}
}

int main()
{
	ll N, M,left;
	cin >> N >> M;
	comb_table(M);

	left = N;
	N /= 1000;

	ll ans;
	if (N >= M) {
		N /= M;
		left -= M * N * 1000;
		left /= 1000;
		ans = C[M][left];
	}
	else 
		ans = C[M][N];
	
	cout << ans << endl;

	return	0;
}
0