結果

問題 No.982 Add
ユーザー polylogKpolylogK
提出日時 2020-02-11 13:34:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 746 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 168,808 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 14:40:54
合計ジャッジ時間 2,492 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 WA -
testcase_03 AC 5 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 4 ms
6,548 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 1 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 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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 * 1000 + b * 1000 + 1, false);
		for(int x = 0; x <= 1000; x++) {
			for(int y = 0; y <= 1000; y++) {
				cnt[a * x + b * y] = true;
			}
		}

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