結果

問題 No.982 Add
ユーザー polylogKpolylogK
提出日時 2020-02-11 13:32:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 726 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 168,684 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 14:39:20
合計ジャッジ時間 3,889 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b; scanf("%d%d", &a, &b);

	if(std::__gcd(a, b) != 1) printf("-1\n");
	else {
		std::vector<bool> cnt(a * b + 1, false);
		for(int x = 0; x <= b; x++) {
			for(int y = 0; y <= a; y++) {
				cnt[a * x + b * y] = true;
			}
		}

		int ans = 0;
		for(auto v: cnt) ans += !v;
		printf("%d\n", ans);
	}
	return 0;
}
0