結果
| 問題 |
No.982 Add
|
| コンテスト | |
| ユーザー |
ate
|
| 提出日時 | 2020-04-19 14:22:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 1,596 bytes |
| コンパイル時間 | 2,232 ms |
| コンパイル使用メモリ | 194,632 KB |
| 最終ジャッジ日時 | 2025-01-09 21:32:49 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
signed main(){
int a,b;
cin>>a>>b;
if(a>b)swap(a,b);
if(a==1){
cout<<0<<endl;
return 0;
}
if(gcd(a,b)!=1){
cout<<-1<<endl;
return 0;
}
vector<bool> num(a*1000+b*1000+1);
for(int x=0;x<=1000;++x)for(int y=0;y<=1000;++y){
num[a*x+b*y]=1;
}
int ans = 0;
for(int i=0;i<=a*b;++i){
if(num[i]==0){
ans++;
dump(i);
}
}
cout<<(ans)<<endl;
}
ate