結果
| 問題 |
No.129 お年玉(2)
|
| コンテスト | |
| ユーザー |
otsnsk
|
| 提出日時 | 2015-01-18 21:44:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 850 bytes |
| コンパイル時間 | 492 ms |
| コンパイル使用メモリ | 55,636 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-22 19:05:41 |
| 合計ジャッジ時間 | 1,730 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 42 |
ソースコード
#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 gcd(ull x, ull y) {
while (y != 0) {
ull t = x % y;
x = y;
y = t;
}
return x;
}
ull count_combinations(ull n, ull k) {
ull r = 1;
for(ull d = 1; d <= k; ++d, --n) {
ull g = gcd(r, d);
r /= g;
ull t = n / (d / g);
r = (r * t) % MODD;
}
return r;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
int M;
cin >> N >> M;
N /= 1000;
N %= M;
cout << count_combinations(M, N%M) << endl;
return 0;
}
otsnsk