結果
問題 | No.800 四平方定理 |
ユーザー | rok_dw |
提出日時 | 2020-05-17 09:12:03 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 953 ms / 2,000 ms |
コード長 | 1,684 bytes |
コンパイル時間 | 1,900 ms |
コンパイル使用メモリ | 174,052 KB |
実行使用メモリ | 67,712 KB |
最終ジャッジ日時 | 2023-10-25 00:47:02 |
合計ジャッジ時間 | 16,724 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
4,348 KB |
testcase_01 | AC | 18 ms
4,872 KB |
testcase_02 | AC | 12 ms
4,368 KB |
testcase_03 | AC | 14 ms
4,368 KB |
testcase_04 | AC | 12 ms
4,368 KB |
testcase_05 | AC | 14 ms
4,368 KB |
testcase_06 | AC | 20 ms
4,872 KB |
testcase_07 | AC | 16 ms
4,872 KB |
testcase_08 | AC | 18 ms
4,872 KB |
testcase_09 | AC | 17 ms
4,872 KB |
testcase_10 | AC | 461 ms
34,484 KB |
testcase_11 | AC | 520 ms
55,384 KB |
testcase_12 | AC | 523 ms
55,384 KB |
testcase_13 | AC | 465 ms
35,804 KB |
testcase_14 | AC | 507 ms
55,384 KB |
testcase_15 | AC | 523 ms
55,384 KB |
testcase_16 | AC | 511 ms
55,384 KB |
testcase_17 | AC | 517 ms
55,384 KB |
testcase_18 | AC | 545 ms
55,384 KB |
testcase_19 | AC | 545 ms
55,384 KB |
testcase_20 | AC | 2 ms
4,348 KB |
testcase_21 | AC | 2 ms
4,348 KB |
testcase_22 | AC | 546 ms
55,384 KB |
testcase_23 | AC | 953 ms
67,712 KB |
testcase_24 | AC | 909 ms
67,712 KB |
testcase_25 | AC | 950 ms
67,712 KB |
testcase_26 | AC | 2 ms
4,348 KB |
testcase_27 | AC | 2 ms
4,348 KB |
testcase_28 | AC | 908 ms
67,712 KB |
testcase_29 | AC | 930 ms
67,712 KB |
testcase_30 | AC | 909 ms
67,712 KB |
testcase_31 | AC | 846 ms
63,616 KB |
testcase_32 | AC | 919 ms
67,712 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define VIN(v) for(auto&elem_: (v) )cin>>elem_ #define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl #define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl #define ALL(a) (a).begin(),(a).end() const ll MOD = 1000000007ll; const int IINF = numeric_limits<int>::max()/2-1; const ll LINF = numeric_limits<ll>::max()/2-1; #define FIX(a) ((a)%MOD+MOD)%MOD int n,d; int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>n>>d;//1<=n<=2000 vl a,b; FOR(x,1,n+1) FOR(y,x,n+1){ a.emplace_back(pow(x,2)+pow(y,2)); if(x!=y) a.emplace_back(pow(x,2)+pow(y,2)); b.emplace_back(pow(y,2)-pow(x,2)); if(x!=y) b.emplace_back(pow(x,2)-pow(y,2)); //x2+y2+z2-w2 } sort(ALL(a)); sort(ALL(b)); ll ans = 0; ll sz = a.size(); REP(i,sz){ ll tmp = upper_bound(ALL(b), d-a[i]) - lower_bound(ALL(b), d-a[i]); ans += tmp; } cout << ans << endl; return 0; }