結果

問題 No.129 お年玉(2)
ユーザー temp
提出日時 2015-02-16 13:24:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 710 ms / 5,000 ms
コード長 1,245 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 70,332 KB
実行使用メモリ 104,576 KB
最終ジャッジ日時 2024-11-27 23:42:03
合計ジャッジ時間 13,825 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
using namespace std;
typedef long long ll;
#define MODN 1000000000
int memo[10001][10001];
ll combi(ll a, ll b) {
if (a < b*2) b = a-b;
if (b == 1) return a;
if (a == b) return 1;
if (a < 10001 && b < 10001 && memo[a][b]) return ll(memo[a][b]);
if (a < 10001 && b < 10001) {
return memo[a][b] = int((combi(a-1, b-1)+combi(a-1, b))%MODN);
}else {
return memo[a][b] = int((combi(a-1, b-1)+combi(a-1, b))%MODN);
}
}
int main() {
ll n, m;
cin >> n;
cin >> m;
ll x = (n-((n/m)-((n/m)%1000))*m)/1000;
// ll ans = 0, u = 1, d = 1;
// for (ll i = m, j = 1; j <= x; i--, j++) {
// if (i%j == 0) {
// u *= i/j;
// }else if ((u*i)%j == 0) {
// u = u*i/j;
// }else if ((u*i)%(d*j) == 0) {
// u = (u*i)/(d*j);
// d = 1;
// }else {
// u *= i;
// d *= j;
// }
// }
// ans = u/d;
// std::cout << x << std::endl;
if (x == 0) {
std::cout << 1 << std::endl;
}else {
std::cout << combi(m, x) << std::endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0