結果
問題 | No.152 貯金箱の消失 |
ユーザー |
|
提出日時 | 2015-02-16 00:14:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 1,072 ms |
コンパイル使用メモリ | 65,996 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 20:35:22 |
合計ジャッジ時間 | 1,515 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>#include <cmath>using namespace std;int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}int main() {int l;cin >> l;l /= 4;int a, b, c;int ans = 0;int limit = ceil(sqrt(l));for (int i = 1; i <= limit; i++) {for (int j = i + 1; j <= limit; j += 2) {if (gcd(i, j) > 1) {continue;}a = j * j - i * i;b = 2 * j * i;c = j * j + i * i;if (a + b + c > l) {break;}ans++;}}cout << ans << endl;return 0;}