結果
| 問題 | No.2066 Simple Math ! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-04 20:46:28 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 676 bytes |
| 記録 | |
| コンパイル時間 | 870 ms |
| コンパイル使用メモリ | 91,144 KB |
| 最終ジャッジ日時 | 2024-11-19 03:39:40 |
| 合計ジャッジ時間 | 1,423 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:7:5: error: 'cin' was not declared in this scope
7 | cin >> t;
| ^~~
main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
1 | #include<atcoder/all>
+++ |+#include <iostream>
2 | using namespace std;
main.cpp:14:13: error: 'cout' was not declared in this scope
14 | cout << g * k << '\n';
| ^~~~
main.cpp:14:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
main.cpp:27:9: error: 'cout' was not declared in this scope
27 | cout << g * ok << '\n';
| ^~~~
main.cpp:27:9: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#include<atcoder/all>
using namespace std;
using ll = long long;
int main(){
int t;
cin >> t;
while(t--){
ll p, q, k, g;
cin >> p >> q >> k;
g = __gcd(p, q);
p /= g, q /= g;
if(p == 1 || q == 1){
cout << g * k << '\n';
continue;
}
auto f = [&](ll v){
ll r = min(q, v / p + 1);
return atcoder::floor_sum(r, q, p, v + q - p * (r - 1));
};
ll ng = 0, ok = 1ll << 60, mid;
while(ng + 1 < ok){
mid = (ng + ok) / 2;
if(f(mid) <= k)ng = mid;
else ok = mid;
}
cout << g * ok << '\n';
}
}