結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2020-12-21 23:43:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 475 bytes |
コンパイル時間 | 1,548 ms |
コンパイル使用メモリ | 165,772 KB |
実行使用メモリ | 103,296 KB |
最終ジャッジ日時 | 2024-09-21 13:22:53 |
合計ジャッジ時間 | 3,964 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; ll n,d; ll c1[8000005],c2[5000005]; ll ans; int main(void){ cin.tie(0); ios::sync_with_stdio(0); cin>>n>>d; for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ c1[i*i+j*j]++; if(i*i-j*j+d>=0){ c2[i*i-j*j+d]++; } } } for(ll i=2;i<=5000000;i++){ ans+=c1[i]*c2[i]; } cout<<ans<<endl; }