結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-03-18 11:51:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 640 bytes |
コンパイル時間 | 1,597 ms |
コンパイル使用メモリ | 157,804 KB |
実行使用メモリ | 64,640 KB |
最終ジャッジ日時 | 2024-07-18 05:05:07 |
合計ジャッジ時間 | 3,721 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<double, int> P; typedef pair<int, P> E; #define MOD (1000000007ll) #define l_ength size #define EPS (1e-10) void add_mod(ll &a, ll b){ a += b; a %= MOD; } void mul_mod(ll &a, ll b){ a *= b; a %= MOD; } ll cnt[8004004]; int main(void){ int n,d,i,j,p; ll ans=0ll; cin >> n >> d; for(i=1; i<=n; ++i){ for(j=1; j<=n; ++j){ ++cnt[i*i+j*j]; } } for(i=1; i<=n; ++i){ for(j=1; j<=n; ++j){ p = j*j-i*i+d; if(0<=p && p<=8000000){ ans += cnt[p]; } } } cout << ans << endl; return 0; }