結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2020-03-14 19:52:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,184 bytes |
コンパイル時間 | 1,781 ms |
コンパイル使用メモリ | 168,724 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 21:27:07 |
合計ジャッジ時間 | 2,403 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 2 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;using p = pair<int, int>;using P = pair<ll, ll>;using V = vector<int>;using VV = vector<vector<int>>;using VVV = vector<vector<vector<int>>>;using VL = vector<ll>;using VVL = vector<vector<ll>>;using VVVL = vector<vector<vector<ll>>>;using Graph = VV;#define rep(i,n) for(int i=0;i<(n);i++)#define all(a) (a).begin(),(a).end()template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }int Inf = (1 << 30);ll inf = (1LL << 60);const int MOD = 1e9 + 7;int main() {int a, b;cin >> a >> b;if (a == 1 || b == 1) {cout << 0 << endl;return 0;}vector<bool> dp(110000, false);dp[0] = true;if (max(a, b) % min(a, b) == 0 || !(a % 2) && !(b % 2)) {cout << -1 << endl;return 0;}rep(i, 100000) {if (dp[i]) {dp[i + a] = true;dp[i + b] = true;}}int ans = 0;rep(i, 100000) if (!dp[i]) ans++;cout << ans << endl;return 0;}