結果
問題 |
No.800 四平方定理
|
ユーザー |
|
提出日時 | 2019-03-17 23:00:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 1,450 ms |
コンパイル使用メモリ | 159,688 KB |
実行使用メモリ | 18,652 KB |
最終ジャッジ日時 | 2024-07-08 01:41:56 |
合計ジャッジ時間 | 8,115 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 4 RE * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; #define mp make_pair #define pb push_back #define pf push_front #define fi first #define se second #define MOD 1000000007 int B[4040404]; int ans,cnt; int main(){ int N,D; cin >> N >> D; for(int i = 1;i<N+1;++i){ for(int j = 1;j<N+1;++j){ B[D-i*i+j*j]++; } } for(int i = 1;i <N+1;++i){ for(int j=1;j<N+1;++j){ /*if(binary_search(A.begin(),A.end(),i*i+j*j)){ cout <<"upp: " <<*upper_bound(A.begin(),A.end(),i*i+j*j)<<endl; cout <<"low: " <<*lower_bound(A.begin(),A.end(),i*i+j*j)<<endl; ans += *upper_bound(A.begin(),A.end(),i*i+j*j)-*lower_bound(A.begin(),A.end(),i*i+j*j)+1; if(B[i*i+j*j]>=1) cnt += B[i*i+j*j]; }*/ if(B[i*i+j*j]>=1) cnt+= B[i*i+j*j]; } } cout << cnt <<endl; return 0; }