問題一覧 > 通常問題

No.982 Add

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 239
作問者 : tubuann1 / テスター : beet
お気に入りにしたユーザー ProblemId : 3872 / 自分の提出
問題文最終更新日: 2020-02-11 13:27:15
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 236 (順位表) の他の問題:

Problem Statement

You are given positive integers $A,B$.
We define $N$ to be a good integer if and only if there exist non-negative integers $x,y$ such that $N=Ax+By$.
Find the number of positive integers that are not good integers.
However, if the number of such integers is not finite, output $-1$.

Input

$A\ B$

$1 \leq A,B \leq 100$
All inputs are integers.

Output

Output the answer on a single line.

Sample

Sample 1
Input
1 2
Output
0

Sample 2
Input
4 18
Output
-1

Sample 3
Input
21 16
Output
150

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。