結果

問題 No.800 四平方定理
ユーザー 661nosyamuzuki
提出日時 2019-03-17 22:39:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 361 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-07-08 00:49:38
合計ジャッジ時間 11,954 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 10 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);
      |         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#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<=n;x++){
	for(y=x;y<=n;y++){
	for(z=y;z<=n;z++){
	for(w=1;w<=n;w++){
		if(x*x+y*y+z*z==w*w+d){
          if(x==y&&y==z)ans++;
          else if(x==y||y==z||z==x)ans+=3;
          else ans+=6;
        }
	}	
	}	
	}	
	}
	printf("%d\n",ans);
	return 0;
}
0