結果
問題 |
No.800 四平方定理
|
ユーザー |
![]() |
提出日時 | 2019-03-15 15:38:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 577 bytes |
コンパイル時間 | 606 ms |
コンパイル使用メモリ | 66,688 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-07-01 19:47:07 |
合計ジャッジ時間 | 30,627 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 TLE * 8 |
ソースコード
#include<iostream> #include<vector> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) const int MAX = 12000001; bool quad[MAX]; int main(){ int n; cin>>n; int d; cin>>d; rep(i,n)quad[(i+1)*(i+1)+d]=1; int ans=0; REP(i,1,n+1)REP(j,i,n+1){ if(i*i+j*j>n*n+d){ continue; } REP(k,j,n+1){ if(quad[i*i+j*j+k*k]){ if(i==j){ if(j==k)++ans; else ans+=3; } else if(i==k||j==k)ans+=3; else ans+=6; } } } cout<<ans<<endl; return 0; }