結果

問題 No.152 貯金箱の消失
ユーザー latte0119latte0119
提出日時 2016-01-22 19:17:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 631 bytes
コンパイル時間 1,326 ms
コンパイル使用メモリ 159,948 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 13:46:46
合計ジャッジ時間 1,967 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef vector<int>vint;
typedef pair<int,int>pint;

const int mod=1000003;

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

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

    L/=4;
    int ans=0;
    for(int n=1;n*n<L;n++){
        for(int m=n+1;m*m<L;m++){
            if((m-n)%2==0)continue;
            if(gcd(m,n)!=1)continue;
            int a=m*m-n*n;
            int b=2*m*n;
            int c=m*m+n*n;
            if(a+b+c<=L)ans++;
        }
    }
    cout<<ans%mod<<endl;
    return 0;
}
0