結果
問題 |
No.800 四平方定理
|
ユーザー |
![]() |
提出日時 | 2019-03-17 21:48:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 480 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 31,932 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-07 21:42:59 |
合計ジャッジ時間 | 4,383 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 5 WA * 5 TLE * 1 -- * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d%d",&n,&d); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<math.h> int main(){ int n,x=1,y=1,z=1,w,d,ans=0; scanf("%d%d",&n,&d); for(x=1;x*x+y*y+z*z-d<=n*n&&x<=n;x++){ for(y=1;x*x+y*y+z*z-d<=n*n&&y<=n;y++){ for(z=1;x*x+y*y+z*z-d<=n*n&&z<=n;z++){ int tmp=-d+x*x+y*y+z*z; tmp=sqrt(tmp); if(x*x+y*y+z*z==tmp*tmp+d){ ans++; // printf("%d,%d,%d,%d\n",x,y,z,tmp); } } z=1; } y=1; } printf("%d\n",ans); return 0; }