結果
問題 | No.129 お年玉(2) |
ユーザー |
![]() |
提出日時 | 2015-01-24 01:33:56 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3,934 ms / 5,000 ms |
コード長 | 641 bytes |
コンパイル時間 | 590 ms |
コンパイル使用メモリ | 60,280 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 23:39:16 |
合計ジャッジ時間 | 42,309 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream> #include <algorithm> #include <sstream> #include <cstdio> using namespace std; #define MOD 1000000000LL typedef long long LL; LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; } int main(int argc, char *argv[]) { string s; getline(cin, s); LL N, M; stringstream ss(s); ss >> N; getline(cin, s); M = atoi(s.c_str()); N /= 1000; N %= M; LL a[10000] = {}; for (LL i = 0; i < N; ++i) { a[i] = i + 1; } LL ans = 1; for (LL i = M-N+1; i <= M; ++i) { LL b = i; for (LL j = 0; j < N; ++j) { LL g = gcd(a[j], b); a[j] /= g, b /= g; } ans = (ans * b) % MOD; } cout << ans << endl; return 0; }