結果
| 問題 |
No.982 Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-12 16:32:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,111 bytes |
| コンパイル時間 | 716 ms |
| コンパイル使用メモリ | 82,832 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-04 01:55:38 |
| 合計ジャッジ時間 | 1,838 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 RE * 3 |
ソースコード
#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 = 2; 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;
}