結果
問題 | No.816 Beautiful tuples |
ユーザー |
|
提出日時 | 2019-08-22 16:52:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,500 ms |
コード長 | 483 bytes |
コンパイル時間 | 2,312 ms |
コンパイル使用メモリ | 192,292 KB |
最終ジャッジ日時 | 2025-01-07 14:38:01 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int a,b; cin>>a>>b; for (int i=1;i*i<=a+b;i++) { if ((a+b)%i!=0) continue; int j=(a+b)/i; if (i!=a&&i!=b&&(a+b)%i==0&&(a+i)%b==0&&(b+i)%a==0) { cout<<i<<endl; return 0; } if (j!=a&&j!=b&&(a+b)%j==0&&(a+j)%b==0&&(b+j)%a==0) { cout<<j<<endl; return 0; } } cout<<-1<<endl; return 0; }