結果
問題 |
No.1936 Rational Approximation
|
ユーザー |
|
提出日時 | 2022-05-13 22:26:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 329 bytes |
コンパイル時間 | 1,631 ms |
コンパイル使用メモリ | 166,076 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-22 02:31:03 |
合計ジャッジ時間 | 2,206 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 WA * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = int64_t; #define rep(i,n) for (int i=0;i<(int)(n);i++) int gccd(int a,int b){ if(a==0) return b; return gccd(b%a,a); } int main(){ int p,q; cin>>p>>q; ll ans=p/gccd(p,q-1)+(q-1)/gccd(p,q-1); ans+=(p-1)/gccd(p-1,q-1)+(q-1)/gccd(p-1,q-1); cout<<ans<<endl; }