結果

問題 No.152 貯金箱の消失
ユーザー mayoko_mayoko_
提出日時 2015-02-15 23:27:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 171 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 73,056 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 01:19:29
合計ジャッジ時間 1,847 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 25 ms
4,376 KB
testcase_08 AC 170 ms
4,376 KB
testcase_09 AC 171 ms
4,376 KB
testcase_10 AC 131 ms
4,380 KB
testcase_11 AC 72 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

const ll MOD = 1000003;

int main(void) {
    ll L;
    cin >> L;
    int ans = 0;
    int limit = 0;
    for (limit = 0; limit*limit <= L; limit++) {}
    for (int n = 1; n < limit; n++) {
        for (int m = n+1; m < limit; m += 2) {
            if (__gcd(m, n) != 1) continue;
            ll a = m*m - n*n;
            ll b = 2*m*n;
            ll c = m*m+n*n;
            if (L >= (a+b+c) * 4) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
0