結果

問題 No.800 四平方定理
ユーザー asdf1asdf1
提出日時 2019-03-17 22:25:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,369 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 145,536 KB
実行使用メモリ 67,104 KB
最終ジャッジ日時 2023-09-22 07:45:29
合計ジャッジ時間 3,669 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,600 KB
testcase_02 AC 2 ms
4,396 KB
testcase_03 AC 2 ms
4,432 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,892 KB
testcase_07 AC 3 ms
4,408 KB
testcase_08 AC 3 ms
6,364 KB
testcase_09 AC 3 ms
4,716 KB
testcase_10 AC 35 ms
36,124 KB
testcase_11 AC 47 ms
38,160 KB
testcase_12 AC 38 ms
38,160 KB
testcase_13 AC 36 ms
36,108 KB
testcase_14 AC 37 ms
38,276 KB
testcase_15 AC 37 ms
38,292 KB
testcase_16 AC 40 ms
40,264 KB
testcase_17 AC 36 ms
40,216 KB
testcase_18 AC 40 ms
40,220 KB
testcase_19 AC 42 ms
40,216 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 37 ms
40,208 KB
testcase_23 AC 78 ms
66,836 KB
testcase_24 AC 82 ms
66,904 KB
testcase_25 AC 77 ms
67,104 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
5,536 KB
testcase_28 AC 75 ms
66,996 KB
testcase_29 AC 76 ms
66,828 KB
testcase_30 AC 83 ms
66,892 KB
testcase_31 AC 74 ms
62,852 KB
testcase_32 AC 85 ms
66,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll kazoe[200*ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>d;
    ll mi=LINF;
    rrep(i,1,n+1){
        rrep(j,1,n+1){
            mi=min(mi,(ll)i*i-j*j);
            mi=min(mi,(ll)i*i+j*j-d);
        }
    }
    mi*=-1;
    mi+=1000;
    rrep(i,1,n+1){  
        rrep(j,1,n+1){
            kazoe[i*i-j*j+mi]++;
        }
    }
    rrep(i,1,n+1){
        rrep(j,1,n+1){
            tmp=i*i+j*j-d;
            ans+=kazoe[tmp+mi];
        }
    }
    Cout(ans);
    return 0;
}
0