結果

問題 No.152 貯金箱の消失
ユーザー h_nosonh_noson
提出日時 2016-02-16 11:39:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 505 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 56,144 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 05:59:04
合計ジャッジ時間 1,189 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

int gcb(int a, int b) {
    if (b == 0)
        return a;
    else if (a > b)
        return gcb(b,a%b);
    else
        return gcb(a,b%a);
}

int main() {
    int l;
    cin >> l;
    l /= 4;
    int ans = 0;
    for (int m = 2; 2*m*(m+m%2+1) <= l; m++) {
        int n;
        for (n = m % 2 + 1; n < m; n+=2) {
            if (gcb(m,n) == 1 && 2*m*(m+n) <= l)
                ans = (ans+1) % 1000003;
        }
    }
    cout << ans << endl;
    return 0;
}
0