結果
問題 | No.129 お年玉(2) |
ユーザー |
|
提出日時 | 2020-04-22 10:40:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3,470 ms / 5,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 804 ms |
コンパイル使用メモリ | 73,068 KB |
最終ジャッジ日時 | 2025-01-09 22:27:00 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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) { auto g = std::gcd(y, p); 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; }