結果

問題 No.152 貯金箱の消失
ユーザー なおなお
提出日時 2014-12-18 15:02:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 67 ms / 5,000 ms
コード長 691 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 145,316 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 18:42:22
合計ジャッジ時間 3,168 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// 想定解: ピタゴラス数の列挙
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void rc(int v,int mn,int mx){if(v<mn||mx<v){cerr<<"error"<<endl;exit(1);}}
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
const int MAXN = 100000000;
const int MOD = 1000003;

ll gcd(ll n, ll m){return m?gcd(m,n%m):n;}

int main(){
    int L;
    cin >> L; rc(L, 1, MAXN);
    L /= 4;
    int maxm = int(sqrt(L+.0))+2;

    int cnt = 0;
    for(int m = 1; m <= maxm; m++){
        for(int n = m-1; n >= 1; n -= 2){
            if(gcd(m,n) != 1) continue;
            if((ll)2*m*(m+n) <= L) cnt++;
        }
    }
    cout << cnt % MOD << endl;
}
0