結果
| 問題 |
No.152 貯金箱の消失
|
| コンテスト | |
| ユーザー |
maine_honzuki
|
| 提出日時 | 2020-05-27 00:00:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 5,000 ms |
| コード長 | 745 bytes |
| コンパイル時間 | 1,534 ms |
| コンパイル使用メモリ | 172,368 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-10-13 03:08:54 |
| 合計ジャッジ時間 | 2,639 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int mod = 1000003;
int gcd(int a, int b) {
while (b) {
int c = b;
b = a % b;
a = c;
}
return a;
}
int main() {
int L;
cin >> L;
L /= 4;
set<pair<int, int>> S;
int ans = 0;
for (int i = 1; i * i < L; i++) {
for (int j = i + 1; j * j < L; j++) {
int x = j * j - i * i;
int y = j * j + i * i;
int z = 2 * i * j;
if (x + y + z > L)
continue;
if (gcd(x, y) != 1)
continue;
if (S.count({x, y}))
continue;
S.insert({x, y});
ans++;
}
}
ans %= mod;
cout << ans << endl;
}
maine_honzuki