結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
tokizo
|
| 提出日時 | 2019-04-20 16:27:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 674 bytes |
| コンパイル時間 | 1,703 ms |
| コンパイル使用メモリ | 170,088 KB |
| 実行使用メモリ | 176,912 KB |
| 最終ジャッジ日時 | 2024-10-01 13:08:04 |
| 合計ジャッジ時間 | 6,075 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 4 TLE * 1 -- * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int a, b;
cin >> a >> b;
int ab = a + b;
vector<bool> F(ab + 1, true);
for(int i = 1; i <= (int)(sqrt(ab)); i++){
if(F[i]){
bool x = (a + b) % i == 0;
bool y = (b + i) % a == 0;
bool z = (i + a) % b == 0;
if(x and y and z){
cout << i << endl;
return 0;
}
if(i == 1) continue;
for(int j = i + i; j <= ab; j += i){
F[j] = false;
}
}
}
cout << -1 << endl;
return 0;
}
tokizo