結果
| 問題 | No.982 Add |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-02-15 02:08:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,131 bytes |
| 記録 | |
| コンパイル時間 | 824 ms |
| コンパイル使用メモリ | 94,820 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-06 13:37:19 |
| 合計ジャッジ時間 | 1,733 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 5 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 982.cc: No.982 Add - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_A = 100;
const int MAX_B = 100;
const int MAX_N = MAX_A * MAX_A + MAX_B * MAX_B;
/* typedef */
/* global variables */
bool used[MAX_N + 1];
/* subroutines */
template <typename T>
T gcd(T m, T n) { // m > 0, n > 0
if (m < n) swap(m, n);
while (n > 0) {
T r = m % n;
m = n;
n = r;
}
return m;
}
/* main */
int main() {
int a, b;
scanf("%d%d", &a, &b);
if (gcd<int>(a, b) > 1) {
puts("-1");
return 0;
}
int maxn = a * a + b * b;
for (int x = 0; x <= a; x++)
for (int y = 0, n; (n = a * x + b * y) <= maxn; y++)
used[n] = true;
int cnt = 0;
for (int n = 0; n <= maxn; n++)
if (! used[n]) cnt++;
printf("%d\n", cnt);
return 0;
}
tnakao0123