結果
問題 | No.816 Beautiful tuples |
ユーザー |
![]() |
提出日時 | 2019-04-20 07:03:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,500 ms |
コード長 | 509 bytes |
コンパイル時間 | 585 ms |
コンパイル使用メモリ | 66,168 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 03:16:23 |
合計ジャッジ時間 | 1,393 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int main(){ ll a, b; cin>>a>>b; vector<ll> d; for(ll c=1; c*c<=a+b; c++){ if((a+b)%c==0){ d.push_back(c); if(c*c<a+b) d.push_back((a+b)/c); } } sort(d.begin(), d.end()); for(auto c:d){ if((a+c)%b==0 && (b+c)%a==0 && c!=a && c!=b){ cout<<c<<endl; return 0; } } cout<<-1<<endl; return 0; }