結果

問題 No.816 Beautiful tuples
ユーザー eQeeQe
提出日時 2019-06-10 20:49:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 891 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 166,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 20:25:47
合計ジャッジ時間 2,251 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
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 1 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

map<ll, ll> mp;

void divisor(ll n) {
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      mp[i]++;
      mp[n/i]++;
    }
  }
}

int main(void) {
  ll a, b;
  cin >> a >> b;
  
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    ll c=it->ft;
    ll ab=a+b, bc=b+c, ca=c+a;
    
    if(ab%c==0 && bc%a==0 && ca%b==0) {
      pt(c);
      return 0;
    }
    
  }
  
  pt(-1);
  
  
}










0