結果

問題 No.1593 Perfect Distance
ユーザー kotatsugamekotatsugame
提出日時 2021-07-09 23:05:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 63,776 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 10:38:42
合計ジャッジ時間 1,888 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 15 ms
4,376 KB
testcase_11 AC 25 ms
4,376 KB
testcase_12 AC 44 ms
4,380 KB
testcase_13 AC 48 ms
4,384 KB
testcase_14 AC 56 ms
4,380 KB
testcase_15 AC 83 ms
4,380 KB
testcase_16 AC 123 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:15:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   15 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
long N;
long isq(long A)
{
	long L=0,R=A+1;
	while(R-L>1)
	{
		long M=L+R>>1;
		if(M<=A/M)L=M;
		else R=M;
	}
	return L;
}
main()
{
	cin>>N;
	long ans=0;
	for(long x=1;x<N;x++)
	{
		long y2=N*N-x*x;
		long y=isq(y2);
		if(y*y==y2)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
}
0