結果

問題 No.152 貯金箱の消失
ユーザー h_noson
提出日時 2016-02-16 11:39:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 505 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 54,636 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 07:16:35
合計ジャッジ時間 1,069 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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