結果
問題 | No.800 四平方定理 |
ユーザー | zeke |
提出日時 | 2019-11-12 21:08:10 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,285 ms / 2,000 ms |
コード長 | 1,421 bytes |
コンパイル時間 | 910 ms |
コンパイル使用メモリ | 100,352 KB |
実行使用メモリ | 36,400 KB |
最終ジャッジ日時 | 2023-10-19 14:09:02 |
合計ジャッジ時間 | 17,782 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
4,348 KB |
testcase_01 | AC | 16 ms
4,348 KB |
testcase_02 | AC | 11 ms
4,348 KB |
testcase_03 | AC | 12 ms
4,348 KB |
testcase_04 | AC | 12 ms
4,348 KB |
testcase_05 | AC | 14 ms
4,348 KB |
testcase_06 | AC | 18 ms
4,348 KB |
testcase_07 | AC | 17 ms
4,348 KB |
testcase_08 | AC | 12 ms
4,348 KB |
testcase_09 | AC | 16 ms
4,348 KB |
testcase_10 | AC | 584 ms
20,296 KB |
testcase_11 | AC | 595 ms
36,400 KB |
testcase_12 | AC | 666 ms
36,400 KB |
testcase_13 | AC | 481 ms
19,896 KB |
testcase_14 | AC | 534 ms
36,400 KB |
testcase_15 | AC | 663 ms
36,400 KB |
testcase_16 | AC | 527 ms
36,400 KB |
testcase_17 | AC | 531 ms
36,400 KB |
testcase_18 | AC | 757 ms
36,400 KB |
testcase_19 | AC | 761 ms
36,400 KB |
testcase_20 | AC | 2 ms
4,348 KB |
testcase_21 | AC | 2 ms
4,348 KB |
testcase_22 | AC | 770 ms
36,400 KB |
testcase_23 | AC | 1,276 ms
36,400 KB |
testcase_24 | AC | 993 ms
36,400 KB |
testcase_25 | AC | 1,285 ms
36,400 KB |
testcase_26 | AC | 2 ms
4,348 KB |
testcase_27 | AC | 2 ms
4,348 KB |
testcase_28 | AC | 978 ms
36,400 KB |
testcase_29 | AC | 1,153 ms
36,400 KB |
testcase_30 | AC | 984 ms
36,400 KB |
testcase_31 | AC | 901 ms
36,400 KB |
testcase_32 | AC | 1,028 ms
36,400 KB |
ソースコード
/* Author:zeke pass System Test! GET AC!! */ #include <iostream> #include <queue> #include <vector> #include <iostream> #include <vector> #include <string> #include <cassert> #include <algorithm> #include <functional> #include <cmath> #include <queue> #include <set> #include <stack> #include <deque> #include <map> #include <iomanip> #include <utility> #include <stack> #include <math.h> using ll = long long; using ld = long double; using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() #define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var)) #define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var)) #define Mp(a,b) make_pair((a),(b)) #define F first #define S second #define CIN(s) int (s);cin>>(s); template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } typedef pair<ll, ll> P; typedef vector<ll> V; typedef vector<V> VV; typedef vector<P> VP; ll MOD = 1e9 + 7; ll INF =1e18; //ここから int main(){ ll n,d; cin>>n>>d; V vec; rep3(i,1,n+1)rep3(j,1,n+1)vec.push_back(i*i+j*j-d); sort(all(vec)); ll res=0; rep3(i,1,n+1)rep3(j,1,n+1){ ll k=i*i-j*j; res+=upper_bound(all(vec),k)-lower_bound(all(vec),k); } cout<<res<<endl; }