結果

問題 No.53 悪の漸化式
ユーザー 184184
提出日時 2014-10-30 23:47:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 529 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 61,564 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 23:31:44
合計ジャッジ時間 1,279 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:13: warning: ‘a2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  else printf("%0.10f\n",a2);
       ~~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h> 
#include <string.h>
#include <math.h>
#include <iostream>
#include <vector>

using namespace std;
 
int main(){
	int n;scanf("%d",&n);
	double a=4,a1=3,a2;
	if(n==0){
		printf("4\n");return 0;
	}
	else if(n==1){
		printf("3\n");return 0;
	}
	
	for(int i=2;i<=n;i++){
		a2=(19/4.0*a1-3.0*a);
		a=a1;
		a1=a2;
		if(a2<(double)1e-9){
			a2=0;
			break;
		}
	}
	if(a2==0)printf("0\n");
	else printf("%0.10f\n",a2);
	//else printf("%0.10f\n",a2);
	
	return 0;
}
0