結果

問題 No.152 貯金箱の消失
ユーザー satanicsatanic
提出日時 2016-05-06 22:59:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 840 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 75,644 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 07:52:12
合計ジャッジ時間 1,730 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int GetGCD(int a, int b){
    int r=-1;
    if(a<b) std::swap(a, b);
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}	

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int l;
    std::cin >> l;
    if(l<48){
        std::cout << "0\n";
        return 0;
    }
    l/=4;
    std::vector<int> len;
    for(int m=2; m<1119; ++m){
        for(int n=m&1?2:1; n<m; n+=2){
            if(GetGCD(m, n)==1){
                len.push_back(2*m*(m+n));
            }
        }
    }
    std::sort(len.begin(), len.end());
    int mi=0, ma=len.size()-1;
    while(ma-mi>1){
        int me=(mi+ma)/2;
        if(l<len[me]) ma=me;
        else          mi=me;
    }
    std::cout << ma%1000003 << "\n";
    return 0;
}
0