結果

問題 No.982 Add
ユーザー chikokuma
提出日時 2020-02-12 16:31:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,111 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 01:55:21
合計ジャッジ時間 1,633 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 7 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>
#include<stdio.h>

using namespace std;

using ll = long long;

#define rep(i, n) for (ll i = 0; i < n; i++)

const ll INF = 1LL << 60;

typedef pair<ll, double> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second < secondElof.second;
}

bool IsPrime(ll num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

bool hako[10005] = { false };

signed main() {
	ll ans = 0;
	ll a, b;
	cin >> a >> b;
	for (ll i = 1; i <= 100; i++) {
		if (a % i == 0 && b % i == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	rep(i, b) {
		rep(j, a) {
			hako[a * i + b * j] = true;
		}
	}

	rep(i, a * b) {
		if (hako[i] == false) {
			ans++;
		}
	}
	cout << ans << endl;
}
0