結果

問題 No.352 カード並べ
ユーザー fiordfiord
提出日時 2016-03-12 00:07:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 23,300 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 06:09:55
合計ジャッジ時間 732 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 0 ms
4,348 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:4:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |         int n;  scanf("%d",&n);
      |                 ~~~~~^~~~~~~~~

ソースコード

diff #

#include <cstdio>
using namespace std;
int main(){
	int n;	scanf("%d",&n);
	/*double ret=2;
	printf("%.15lf\n",ret);
	for(int i=2;i<n;i++){//現在机の上の枚数
		//f(3):2*2!+(1*2)*2!
		//f(4):2*3!+(1*(2+3)+2*3)*2*1!
		//f(n):2*(n-1)!+(1*(2+3+...+(n-1))+2*(...)...)*(n-2)*(n-3)!
		//g(n)=f(n)/(n-1)!/n
		//    =2/n+2*(1*(2+3+...+(n-1))+2*(...)...)/n(n-1)
		double add=2.0,add2=0;
		for(int j=1;j<i;j++){
			//add2にj*((j+1)+(j+2)+(j+3)+...+i)
			add2+=j*(j+1+i)*(i-j)/2.0;
		}
		ret+=add/(i+1)+2*add2/i/(i+1);
		printf("%.15lf\n",ret);
	}*/
	double ans[]={2.000000000000000,3.333333333333333,5.666666666666667,9.566666666666666,15.566666666666666,24.185714285714287,35.935714285714283,51.324603174603169,70.857936507936500,95.039754689754687,124.373088023088016,159.360267510267505,200.503124653124644,248.303124653124655,303.261457986457970,365.879105045281506,436.656882823059277,516.095479314287331,604.695479314287354};
	printf("%.15lf\n",ans[n-2]);
	return 0;
}
0