結果
問題 | No.129 お年玉(2) |
ユーザー |
![]() |
提出日時 | 2015-01-18 22:10:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 67 ms / 5,000 ms |
コード長 | 873 bytes |
コンパイル時間 | 582 ms |
コンパイル使用メモリ | 54,748 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 23:43:48 |
合計ジャッジ時間 | 3,237 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream>#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)#define FOR(i,e) FORR(i,0,e)#define dump(var) cerr << #var ": " << var << "\n"#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"typedef long long ll;typedef unsigned long long ull;const ull MODD = 1e9;using namespace std;ull pt[2][10100];ull count_combinations_pascal(ull n, ull k) {fill(pt[0], pt[0]+10100, 0);fill(pt[1], pt[1]+10100, 0);pt[0][0] = pt[1][0] = 1;for (int i = 1; i <= n; ++i) {ull *ra = pt[(i-1)&1], *rb = pt[i&1];for (int j = 1; j <= i + 1; ++j) {rb[j] = (ra[j-1] + ra[j]) % MODD;}}return pt[n&1][k];}int main() {cin.tie(0);ios::sync_with_stdio(false);ull N, M;cin >> N >> M;N /= 1000;cout << count_combinations_pascal(M, N%M) << endl;return 0;}