結果
問題 | No.816 Beautiful tuples |
ユーザー | nu50218 |
提出日時 | 2019-04-19 21:54:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,483 bytes |
コンパイル時間 | 1,584 ms |
コンパイル使用メモリ | 175,476 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-22 18:51:39 |
合計ジャッジ時間 | 2,171 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast; /* define */ #define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++) #define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--) #define ALL(X) (X).begin(),(X).end() #define pb push_back #define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)) #define debug(x) cerr<<#x<<':'<<x<<endl; #define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl; #define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} #define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} #define ctoi(C) (C-'0') #define pow2(x) ((long long)((long long)1<<x)) /* alias */ using ll = long long; using ld = long double; using vi = vector<int>; using vii = vector<vector<int>>; using vl = vector<long long>; using vll = vector<vector<long long>>; using pi = pair<int,int>; using pl = pair<long long,long long>; template<typename T> using PQ = priority_queue<T>; template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>; /* const */ const long long dx[] = {1,0,-1,0}; const long long dy[] = {0,1,0,-1}; const long long dx8[] = {1,1,0,-1,-1,-1,0,1}; const long long dy8[] = {0,1,1,1,0,-1,-1,-1}; const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0}; const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0}; const int INF = 1000000007; const long long LINF = 1000000000000000007; /* func */ template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;} template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;} long long max(long long x,int y){return max(x,(long long)y);} long long max(int x,long long y){return max((long long)x,y);} long long min(long long x,int y){return min(x,(long long)y);} long long min(int x,long long y){return min((long long)x,y);} /* liblary */ vector<long long> Factorize(long long n){ vector<long long> ans; for(long long i = 1;i*i <= n;i++){ if(n%i == 0)ans.push_back(i); } ans.push_back(n); return ans; } /* main */ ll A,B; bool check(ll C){ if(A == C || B == C)return false; if((A+B)%C || (B+C)%A || (C+A)%B)return false; return true; } signed main(){ cin >> A >> B; vl v = Factorize(A+B); set<ll> s; for(auto x:v)s.insert(x); for(auto x:s){ if(check(x)){ cout << x << endl; return 0; } } cout << -1 << endl; }