結果
問題 | No.982 Add |
ユーザー |
|
提出日時 | 2020-02-12 16:26:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,073 bytes |
コンパイル時間 | 754 ms |
コンパイル使用メモリ | 82,960 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 01:54:46 |
合計ジャッジ時間 | 2,499 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 3 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;if (a % 2 == 0 && b % 2 == 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;}