結果

問題 No.186 中華風 (Easy)
ユーザー motimoti
提出日時 2015-11-29 23:01:43
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,215 bytes
コンパイル時間 874 ms
コンパイル使用メモリ 103,932 KB
実行使用メモリ 427,616 KB
最終ジャッジ日時 2023-10-12 05:56:26
合計ジャッジ時間 7,230 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define minimize(a, x) a = std::min(a, x)
#define maximize(a, x) a = std::max(a, x)

typedef unsigned long long ll;
int const inf = 1<<29;

int main() {

  int xs[3], ys[3];
  rep(i, 3) {
    cin >> xs[i] >> ys[i];
  }

  set<ll> s;
  ll curr = xs[0];
  rep(i, 1e8) {
    s.insert(curr);
    curr += ys[0];
    if(curr >= std::numeric_limits<ll>::max() - ys[0]) { break; }
  }

  set<ll> t;
  for(auto& e: s) {
    if(e % ys[1] == xs[1]) {
      t.insert(e);
    }
  }

  curr = xs[2];
  for(auto& e: t) {
    if(e % ys[2] == xs[2]) {
      cout << e << endl;
      exit(0);
    }
  }

  cout << -1 << endl;

  return 0;
}
0