結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2020-04-15 15:50:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 118 ms / 2,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 93,636 KB |
実行使用メモリ | 72,320 KB |
最終ジャッジ日時 | 2024-10-01 18:47:18 |
合計ジャッジ時間 | 4,472 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
// I SELL YOU...! #include<iostream> #include<vector> #include<algorithm> #include<functional> #include<queue> #include<chrono> #include<iomanip> #include<map> #include<set> using namespace std; using ll = long long; using P = pair<ll,ll>; using TP = tuple<ll,ll,ll>; void init_io(){ cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(18); } #define MAX 2*(2100*2100) vector<ll> mv(MAX,0); signed main(){ init_io(); ll n,d,ans=0; cin >> n >> d; for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ mv[i*i+j*j]++; } } for(ll w=1;w<=n;w++){ for(ll z=1;z<=n;z++){ ll x = d + w*w - z*z; if(x>=0&&x<MAX){ ans += mv[x]; } } } cout << ans << endl; }