結果

問題 No.152 貯金箱の消失
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-08-09 17:28:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 794 bytes
コンパイル時間 2,902 ms
コンパイル使用メモリ 144,184 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 13:17:50
合計ジャッジ時間 2,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

//gcd
template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    int L; cin >> L;
    ll ans = 0;
    for (int i = 2; 8*i*i < L; i++) {
        for (int j = 1; 8 * i*(i + j) <= L; j++) {
            if (i <= j) break;
            if (gcd(i*i-j*j,gcd(2*i*j,i*i+j*j))!=1) continue;
            ans++;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}
0