結果
| 問題 | 
                            No.816 Beautiful tuples
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-05-23 23:49:04 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 725 bytes | 
| コンパイル時間 | 676 ms | 
| コンパイル使用メモリ | 74,792 KB | 
| 実行使用メモリ | 13,756 KB | 
| 最終ジャッジ日時 | 2024-09-17 09:55:33 | 
| 合計ジャッジ時間 | 4,523 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 5 TLE * 1 -- * 9 | 
ソースコード
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;
void SetDivisor(vector<int>& vec,int n)
{
    int rt=static_cast<int>(sqrt(n));
    for(int i=1;i<=n;i++)
    {
        if(n%i==0)vec.push_back(i);
    }
}
int main()
{
    vector<int> d;
    d.push_back(-1);
    int buf;
    int a,b;
    cin>>a>>b;
    buf=a+b;
    SetDivisor(d,buf);
    int index=0;
    for(int i=1;i<d.size();i++)
    {
        if((d[i]+b)%a==0)
        {
            if((a+d[i])%b==0)
            {
                if(d[i]!=a && d[i]!=b)
                {
                    index=i;
                    break;
                }
            }
        }
    }
    cout<<d[index]<<endl;
    return 0;
}