結果

問題 No.982 Add
ユーザー KKT89KKT89
提出日時 2020-02-11 13:58:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 96,740 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 14:49:36
合計ジャッジ時間 1,879 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 5 ms
6,548 KB
testcase_03 AC 14 ms
6,548 KB
testcase_04 AC 1 ms
6,548 KB
testcase_05 AC 9 ms
6,548 KB
testcase_06 AC 4 ms
6,548 KB
testcase_07 AC 7 ms
6,548 KB
testcase_08 AC 6 ms
6,548 KB
testcase_09 AC 17 ms
6,548 KB
testcase_10 AC 18 ms
6,548 KB
testcase_11 AC 13 ms
6,548 KB
testcase_12 AC 4 ms
6,548 KB
testcase_13 AC 4 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 6 ms
6,548 KB
testcase_16 AC 9 ms
6,548 KB
testcase_17 AC 5 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 19 ms
6,548 KB
testcase_25 AC 19 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0