結果

問題 No.186 中華風 (Easy)
ユーザー kosakkunkosakkun
提出日時 2016-12-27 18:22:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 1,432 bytes
コンパイル時間 958 ms
コンパイル使用メモリ 90,484 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 00:50:11
合計ジャッジ時間 3,100 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
4,380 KB
testcase_01 AC 25 ms
4,376 KB
testcase_02 AC 59 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 54 ms
4,380 KB
testcase_05 AC 64 ms
4,380 KB
testcase_06 AC 140 ms
4,380 KB
testcase_07 AC 49 ms
4,376 KB
testcase_08 AC 64 ms
4,380 KB
testcase_09 AC 61 ms
4,380 KB
testcase_10 AC 186 ms
4,376 KB
testcase_11 AC 86 ms
4,376 KB
testcase_12 AC 16 ms
4,376 KB
testcase_13 AC 91 ms
4,376 KB
testcase_14 AC 18 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 85 ms
4,380 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 31 ms
4,376 KB
testcase_19 AC 12 ms
4,376 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

long long gcd(long long a, long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long a, long long b){
    return a*b/gcd(a,b);
}

int main(){
    
    ll X[3],Y[3];
    REP(i,3)cin>>X[i]>>Y[i];
    
    for(ll i=0;i<Y[1];i++){
        if((Y[0]*i+X[0])%Y[1]==X[1]){
            for(ll j=0;j<Y[2];j++){
                ll ans=lcm(Y[0],Y[1])*j + Y[0]*i+X[0];
                if(ans%Y[2]==X[2]){
                    if(ans!=0){
                        cout<<ans<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<-1<<endl;
    
    return 0;
}
0