結果

問題 No.800 四平方定理
ユーザー 沙耶花沙耶花
提出日時 2020-11-28 16:40:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 200,780 KB
実行使用メモリ 81,284 KB
最終ジャッジ日時 2023-10-10 00:42:02
合計ジャッジ時間 6,028 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
81,284 KB
testcase_01 AC 22 ms
81,060 KB
testcase_02 AC 21 ms
81,032 KB
testcase_03 AC 23 ms
80,964 KB
testcase_04 AC 22 ms
81,032 KB
testcase_05 AC 23 ms
81,032 KB
testcase_06 AC 22 ms
80,984 KB
testcase_07 AC 22 ms
80,984 KB
testcase_08 AC 22 ms
81,048 KB
testcase_09 AC 23 ms
81,056 KB
testcase_10 AC 55 ms
81,028 KB
testcase_11 AC 57 ms
81,116 KB
testcase_12 AC 59 ms
81,004 KB
testcase_13 AC 52 ms
81,032 KB
testcase_14 AC 54 ms
80,976 KB
testcase_15 AC 56 ms
80,988 KB
testcase_16 AC 54 ms
81,136 KB
testcase_17 AC 54 ms
81,036 KB
testcase_18 AC 61 ms
81,048 KB
testcase_19 AC 60 ms
80,976 KB
testcase_20 AC 22 ms
80,980 KB
testcase_21 AC 21 ms
81,028 KB
testcase_22 AC 61 ms
80,976 KB
testcase_23 AC 102 ms
81,032 KB
testcase_24 AC 90 ms
81,036 KB
testcase_25 AC 96 ms
81,272 KB
testcase_26 AC 22 ms
81,028 KB
testcase_27 AC 21 ms
81,280 KB
testcase_28 AC 92 ms
81,036 KB
testcase_29 AC 97 ms
81,032 KB
testcase_30 AC 94 ms
81,028 KB
testcase_31 AC 85 ms
81,044 KB
testcase_32 AC 96 ms
80,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000000



int main(){
	
	int N,D;
	cin>>N>>D;
	
	vector<long long> cnt(10000000,0LL);

	
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			cnt[i*i+j*j]++;
		}
	}
	
	long long ans = 0LL;
	
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			int t = i*i-j*j+D;
			if(t<0)continue;
			ans += cnt[t];
		}
	}
	
	cout<<ans<<endl;
		
	
    return 0;
}
0