結果

問題 No.800 四平方定理
ユーザー kotatsugamekotatsugame
提出日時 2019-03-17 23:48:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 877 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 75,324 KB
実行使用メモリ 21,092 KB
最終ジャッジ日時 2023-09-22 15:41:32
合計ジャッジ時間 13,483 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,376 KB
testcase_01 AC 13 ms
4,376 KB
testcase_02 AC 9 ms
4,376 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 10 ms
4,376 KB
testcase_06 AC 15 ms
4,376 KB
testcase_07 AC 11 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 13 ms
4,376 KB
testcase_10 AC 401 ms
12,692 KB
testcase_11 AC 435 ms
20,496 KB
testcase_12 AC 454 ms
19,940 KB
testcase_13 AC 384 ms
11,876 KB
testcase_14 AC 413 ms
19,384 KB
testcase_15 AC 454 ms
19,936 KB
testcase_16 AC 417 ms
19,860 KB
testcase_17 AC 419 ms
20,300 KB
testcase_18 AC 482 ms
19,964 KB
testcase_19 AC 487 ms
20,008 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 485 ms
21,088 KB
testcase_23 AC 876 ms
21,012 KB
testcase_24 AC 784 ms
21,092 KB
testcase_25 AC 877 ms
19,604 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 773 ms
20,208 KB
testcase_29 AC 839 ms
19,392 KB
testcase_30 AC 777 ms
19,776 KB
testcase_31 AC 715 ms
20,008 KB
testcase_32 AC 799 ms
19,632 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,d;
vector<int>a;
main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)a.push_back(i*i-j*j);
	sort(a.begin(),a.end());
	int ans=0;
	for(int i=1;i<=n;i++)for(int j=i;j<=n;j++)
		ans+=(upper_bound(a.begin(),a.end(),i*i+j*j-d)-lower_bound(a.begin(),a.end(),i*i+j*j-d))*(1+(i<j));
	cout<<ans<<endl;
}
0