結果
| 問題 |
No.2526 Kth Not-divisible Number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-03 21:23:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 276 ms / 2,000 ms |
| コード長 | 436 bytes |
| コンパイル時間 | 480 ms |
| コンパイル使用メモリ | 64,000 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 19:18:15 |
| 合計ジャッジ時間 | 4,328 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int gcd(int a,int b)
{
while(b)
{
int t=a%b;
a=b;
b=t;
}
return a;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
for(;T--;)
{
int A,B;
long K;
cin>>A>>B>>K;
int g=gcd(A,B);
long lcm=(long)A/g*B;
long L=0,R=4e18;
while(R-L>1)
{
long M=(L+R)/2;
if(M-(M/A+M/B-M/lcm)>=K)R=M;
else L=M;
}
cout<<R<<"\n";
}
}