結果

問題 No.982 Add
コンテスト
ユーザー KKT89
提出日時 2020-02-11 13:51:09
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 653 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 573 ms
コンパイル使用メモリ 112,632 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-25 07:55:50
合計ジャッジ時間 2,582 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 17 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
    }
    int ans=0;
    for(int i=1;i<=100*100;i++){
        bool ok=0;
        for(int j=0;j<=100;j++){
            if(i-a*j>=0){
                if((i-a*j)%b==0){
                    ok=1;
                    break;
                }
            }
            else break;
        }
        if(!ok)ans++;
    }
    cout << ans << endl;
}
0