結果
問題 |
No.800 四平方定理
|
ユーザー |
![]() |
提出日時 | 2019-03-17 21:36:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 336 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 31,616 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 20:59:38 |
合計ジャッジ時間 | 1,099 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 2 WA * 28 |
コンパイルメッセージ
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&&x<=n;x++){ for(y=1;x*x+y*y+z*z<d&&y<=n;y++){ for(z=1;x*x+y*y+z*z<d&&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\n",ans); return 0; }