結果

問題 No.982 Add
ユーザー polylogKpolylogK
提出日時 2020-02-11 13:36:42
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 1,444 ms
使用メモリ 3,672 KB
最終ジャッジ日時 2022-11-24 17:21:15
合計ジャッジ時間 2,627 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,672 KB
testcase_01 AC 1 ms
3,588 KB
testcase_02 AC 1 ms
3,652 KB
testcase_03 AC 1 ms
3,652 KB
testcase_04 AC 1 ms
3,580 KB
testcase_05 AC 2 ms
3,576 KB
testcase_06 AC 1 ms
3,568 KB
testcase_07 AC 1 ms
3,612 KB
testcase_08 AC 1 ms
3,600 KB
testcase_09 AC 1 ms
3,576 KB
testcase_10 AC 2 ms
3,564 KB
testcase_11 AC 1 ms
3,568 KB
testcase_12 AC 1 ms
3,600 KB
testcase_13 AC 2 ms
3,568 KB
testcase_14 AC 1 ms
3,560 KB
testcase_15 AC 1 ms
3,564 KB
testcase_16 AC 1 ms
3,564 KB
testcase_17 AC 1 ms
3,560 KB
testcase_18 AC 1 ms
3,504 KB
testcase_19 AC 1 ms
3,500 KB
testcase_20 AC 1 ms
3,432 KB
testcase_21 AC 2 ms
3,508 KB
testcase_22 AC 2 ms
3,564 KB
testcase_23 AC 1 ms
3,540 KB
testcase_24 AC 2 ms
3,608 KB
testcase_25 AC 1 ms
3,576 KB
権限があれば一括ダウンロードができます

ソースコード

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(2 * 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 >> 1);
	}
	return 0;
}
0