結果
| 問題 |
No.129 お年玉(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-22 10:42:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 637 ms / 5,000 ms |
| コード長 | 826 bytes |
| コンパイル時間 | 755 ms |
| コンパイル使用メモリ | 72,856 KB |
| 最終ジャッジ日時 | 2025-01-09 22:27:18 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
#include <iostream>
#include <numeric>
#include <vector>
using lint = long long;
constexpr lint MOD = 1000000000;
template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
void solve() {
lint n, m;
std::cin >> n >> m;
n /= 1000;
n %= m;
std::vector<lint> ps(n);
std::iota(ps.begin(), ps.end(), m - n + 1);
for (lint x = 1; x <= n; ++x) {
lint y = x;
for (auto& p : ps) {
if (p == 1) continue;
auto g = std::gcd(y, p);
if (g == 1) continue;
p /= g;
y /= g;
}
}
lint ans = 1;
for (auto p : ps) (ans *= p) %= MOD;
std::cout << ans << std::endl;
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}