結果
問題 | No.129 お年玉(2) |
ユーザー |
|
提出日時 | 2015-06-10 18:06:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,485 ms / 5,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 384 ms |
コンパイル使用メモリ | 57,792 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-27 23:49:25 |
合計ジャッジ時間 | 16,548 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }