結果
問題 |
No.129 お年玉(2)
|
ユーザー |
|
提出日時 | 2015-01-17 00:19:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 878 bytes |
コンパイル時間 | 709 ms |
コンパイル使用メモリ | 62,936 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 13:15:34 |
合計ジャッジ時間 | 2,978 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 41 |
ソースコード
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; const int mod = 1000000000; int main() { long long n, m; cin >> n >> m; long long atari = (n - (n / 1000 / m) * 1000 * m) / 1000; // cout << atari << endl; long long ans; if (n == 0) { ans = 0; } else{ ans = 1; long long small = min(atari, m - atari); vector<int> left, right; for (int i = 0; i < small; i++) { left.push_back(m - i); right.push_back(i + 1); } for (int i = 0; i < small; i++) { for (int j = 0; j <= small; j++) { if (right[j] > 1 && left[i] % right[j] == 0) { left[i] /= right[j]; right[j] = 1; } } } for (int i = 0; i < small; i++) { ans *= left[i]; } for (int i = 2; i <= small; i++) { if (right[i] > 1) { ans /= right[i]; } } } ans %= mod; cout << ans << endl; return 0; }