結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2020-03-14 19:54:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,105 bytes |
コンパイル時間 | 1,439 ms |
コンパイル使用メモリ | 170,036 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-23 21:27:09 |
合計ジャッジ時間 | 2,278 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 16 WA * 7 |
ソースコード
#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;vector<bool> dp(110000, false);dp[0] = true;rep(i, 100000) {if (dp[i]) {dp[i + a] = true;dp[i + b] = true;}}int ans = 0;rep(i, 100000) {if (!dp[i]) ans++;if (i >= 100000 && !dp[i]) {cout << -1 << endl;return 0;}}cout << ans << endl;return 0;}