結果

問題 No.1593 Perfect Distance
コンテスト
ユーザー bal4u
提出日時 2021-08-11 19:11:26
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 358 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 31,488 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-25 05:33:19
合計ジャッジ時間 1,169 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 1593 Perfect Distance
// 2021.8.11

#include <stdio.h>
#include <math.h>

typedef long long ll;

int main() {
	int N, i, j, ans = 0;
	ll N2;

	scanf("%d", &N), N2 = (ll)N*N;
	int k = N/sqrt(2)+1;
	for (i = 1; i <= k; ++i) {
		ll t = N2-i*i;
		if (t < 0) continue;
		j = sqrt(t);
		if (j*j == t && i < j) ++ans;
	}
	printf("%d\n", 2*ans);
	return 0;
}
0