結果
問題 | No.982 Add |
ユーザー |
|
提出日時 | 2020-02-11 14:50:34 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 656 ms / 2,000 ms |
コード長 | 1,764 bytes |
コンパイル時間 | 1,498 ms |
使用メモリ | 21,576 KB |
最終ジャッジ日時 | 2022-11-24 17:55:16 |
合計ジャッジ時間 | 8,704 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 156 ms
3,832 KB |
testcase_01 | AC | 1 ms
3,540 KB |
testcase_02 | AC | 254 ms
6,948 KB |
testcase_03 | AC | 250 ms
9,516 KB |
testcase_04 | AC | 2 ms
3,412 KB |
testcase_05 | AC | 335 ms
13,300 KB |
testcase_06 | AC | 292 ms
12,540 KB |
testcase_07 | AC | 320 ms
11,664 KB |
testcase_08 | AC | 257 ms
6,908 KB |
testcase_09 | AC | 440 ms
19,316 KB |
testcase_10 | AC | 422 ms
16,992 KB |
testcase_11 | AC | 251 ms
9,468 KB |
testcase_12 | AC | 195 ms
5,088 KB |
testcase_13 | AC | 247 ms
6,784 KB |
testcase_14 | AC | 219 ms
6,544 KB |
testcase_15 | AC | 289 ms
8,660 KB |
testcase_16 | AC | 341 ms
15,152 KB |
testcase_17 | AC | 290 ms
12,672 KB |
testcase_18 | AC | 1 ms
3,496 KB |
testcase_19 | AC | 2 ms
3,388 KB |
testcase_20 | AC | 1 ms
3,548 KB |
testcase_21 | AC | 2 ms
3,576 KB |
testcase_22 | AC | 1 ms
3,384 KB |
testcase_23 | AC | 1 ms
3,564 KB |
testcase_24 | AC | 634 ms
21,576 KB |
testcase_25 | AC | 656 ms
21,508 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define FORR(i, m, n) for (int i = (m); i >= (n); i--) #define REP(i, n) FOR(i, 0, (n)) #define REPR(i, n) FORR(i, (n) - 1, 0) #define REP1(i, n) FOR(i, 1, (n) + 1) #define REPS(c, s) for (char c : s) #define ALL(c) (c).begin(), (c).end() #define SORT(c) sort(ALL(c)) #define REV(c) reverse(ALL(c)) #define sz(v) (int)v.size() #define endl '\n' template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} const int MOD = 1000000007; const int INF = 1000000001; const ll LINF = 1000000001000000001LL; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(numeric_limits<double>::max_digits10); solve(); return 0; } void solve() { int a, b; cin >> a >> b; if (a % 2 == 0 && b % 2 == 0) { cout << -1 << endl; return; } if (a > b) swap(a, b); bool ok = true; REP1(i, b - 1) { bool k = false; REP1(j, b) { if ((a * j) % b == i) { k = true; break; } } if (!k) { ok = false; break; } } if (!ok) { cout << - 1 << endl; return; } set<int> s; REP(i, 2000) REP(j, 2000) { s.emplace(a * i + b * j); } int ans = 0; REP1(i, *(prev(s.end())) * 2 / 3) { if (s.count(i) == 0) ans++; } // cout << a * 999 + b * 999 << endl; // cout << *(prev(s.end())) << endl; cout << ans << endl; }