結果
| 問題 |
No.982 Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-11 13:58:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 697 bytes |
| コンパイル時間 | 950 ms |
| コンパイル使用メモリ | 95,384 KB |
| 最終ジャッジ日時 | 2025-01-08 23:33:56 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int a,b; cin >> a >> b;
if(__gcd(a,b)!=1){
cout << -1 << endl;
return 0;
}
int ans=0;
for(int i=1;i<=100*1000;i++){
bool ok=0;
for(int j=0;j<=1000;j++){
if(i-a*j>=0){
if((i-a*j)%b==0){
ok=1;
break;
}
}
else break;
}
if(!ok){
ans++;
}
}
cout << ans << endl;
}