結果
問題 |
No.442 和と積
|
ユーザー |
![]() |
提出日時 | 2016-11-12 00:27:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 555 bytes |
コンパイル時間 | 505 ms |
コンパイル使用メモリ | 55,228 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 10:43:44 |
合計ジャッジ時間 | 4,077 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | AC * 3 RE * 15 |
ソースコード
#include<iostream> #include<cstdio> using namespace std; unsigned long long int gcd(unsigned long long int a,unsigned long long int b){ if(a==0||b==0) return 0; while(a!=b){ if(a>b) a%=b; else b%=a; } return a; } int main(){ unsigned long long int a,b; unsigned long long int x; cin>>a>>b; unsigned long long int aplsb,amltb; if(a==1||b==1){ cout<<1<<endl; return 0; } x=gcd(a,b); aplsb=(a+b)/x; amltb=(a/x)*(b/x); cout<<x*gcd(aplsb,x*amltb)<<endl; return 0; }