結果

問題 No.152 貯金箱の消失
ユーザー face4face4
提出日時 2018-08-29 18:56:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 546 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 64,016 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 20:39:01
合計ジャッジ時間 1,211 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// mod要らなくない...?
#include<iostream>
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}

bool coprime(int i, int j){
    return gcd(i, j) == 1;
}

int main(){
    int l;
    cin >> l;

    int ans = 0;
    for(int m = 2; 8*m*m <= l; m++){
        for(int n = 1; n < m; n++){
            if((m-n)%2 == 0 || !coprime(n,m))    continue;
            int tmplen = 4*(2*m*m + 2*m*n);
            if(tmplen <= l){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}
0