結果
問題 |
No.1350 2019-6problem
|
ユーザー |
![]() |
提出日時 | 2021-01-17 21:09:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 1,784 ms |
コンパイル使用メモリ | 191,820 KB |
最終ジャッジ日時 | 2025-01-18 01:57:03 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int main(){ ll a,b,k; cin>>a>>b>>k; if(a==b){ cout<<a*k<<endl; return 0; } if(a>b) swap(a,b); if(b%a==0){ cout<<a*k<<endl; return 0; } ll l=lcm(a,b); ll p=l/a+l/b-1; if(k%p==0){ cout<<k/p*l<<endl; return 0; } ll ans=0; ans+=k/p*l; k-=k/p*p; if(a*k/(a+b)!=a*(k+1)/(a+b)) ans+=a*(k+1)/(a+b)*b; else ans+=b*(k+1)/(a+b)*a; cout<<ans<<endl; return 0; }