結果
| 問題 | No.129 お年玉(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-10 18:06:27 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 738 ms / 5,000 ms |
| コード長 | 645 bytes |
| 記録 | |
| コンパイル時間 | 613 ms |
| コンパイル使用メモリ | 74,316 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-22 04:22:04 |
| 合計ジャッジ時間 | 9,909 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
#include <cassert>
#include <iostream>
#include <algorithm>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
const int N = 10010;
int a[N];
int main(void){
ll n,m;
cin >> n >> m;
n /= 1000;
n %= m;
// C(m, n)
REP(i, 0, n) {
a[i] = m - i;
}
REP(i, 2, n + 1) {
int v = i;
REP(j, 0, n) {
int g = __gcd(a[j], v);
a[j] /= g;
v /= g;
if (v == 1) {
break;
}
}
if (v != 1) {
assert(! "not found");
}
}
ll sum = 1;
const ll mod = 1e9;
REP(i, 0, n) {
sum *= a[i];
sum %= mod;
}
cout << sum << endl;
}