結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2020-03-14 19:59:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,151 bytes |
コンパイル時間 | 1,495 ms |
コンパイル使用メモリ | 168,476 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 21:27:22 |
合計ジャッジ時間 | 2,310 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#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;for (int i = 2; i <= max(a, b); i++) {if (a % i == 0 && b % i == 0) {cout << -1 << endl;return 0;}}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++;}cout << ans << endl;return 0;}