結果
問題 | No.152 貯金箱の消失 |
ユーザー |
![]() |
提出日時 | 2015-05-26 18:32:41 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 59 ms / 5,000 ms |
コード長 | 745 bytes |
コンパイル時間 | 503 ms |
コンパイル使用メモリ | 60,220 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 08:50:50 |
合計ジャッジ時間 | 1,113 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#include <iostream> #include <cmath> using namespace std; long long gcd(long long x, long long y) { do { if (x < y) { std::swap(x, y); } x = x % y; } while (x > 0LL); return y; } int main() { long long l; cin >> l; long long patterns = 0; long long total = l / 4; for (long long m = 1; m < (long long)sqrt(total); ++m) { for (long long n = 1; n < m; ++n) { if ((m - n) % 2 == 0) { continue; } if (gcd(m, n) > 1) { continue; } long long a = m * m - n * n; long long b = 2 * m * n; long long c = m * m + n * n; if (a + b + c > total) { continue; } if (a * a + b * b != c * c) { continue; } ++patterns; patterns %= 1000003; } } cout << patterns << endl; return 0; }