AtCoder Grand Contest 007

Submission #1356376

Source codeソースコード

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

/*
N:項数 D:初項 X:項差
項数は玉左右移動の分で、玉の数の2倍ある。
*/
LD f(int N,LD D,LD X){
	//LD ans = 1.0*(D + D+X*(N-1) )*N/2/N;
	LD ans = 1.0*(2.0*D + X*(N-1) )/2.0;
	//cerr << ans << " ";
	LD res;
	LD nextD,nextX;//初項と、項差
	nextD = 1.0*(1.0*(N+2)*D + 5*X)/(N);
	nextX = 1.0*(4+N)*X/(N);
	if( N > 2 ){
		//cerr << nextD << " " << nextX << endl;
		ans += f(N-2,nextD,nextX) ;
	}
	return ans;
}
void solve(){
	int N;
	LD d,x;
	cin >> N >> d >> x;
	LD ans = f(2*N,d,x);
	cout << ans << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()

Submission

Task問題 C - Pushing Balls
User nameユーザ名 akarin55
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1000
Source lengthソースコード長 1734 Byte
File nameファイル名
Exec time実行時間 12 ms
Memory usageメモリ使用量 15872 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0.txt,example1.txt,example2.txt
All 1000 / 1000 000.txt,001.txt,002.txt,003.txt,004.txt,005.txt,006.txt,007.txt,008.txt,009.txt,010.txt,011.txt,012.txt,013.txt,014.txt,015.txt,016.txt,017.txt,018.txt,019.txt,020.txt,021.txt,022.txt,023.txt,024.txt,025.txt,026.txt,027.txt,028.txt,029.txt,030.txt,031.txt,example0.txt,example1.txt,example2.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
000.txt AC 1 ms 256 KB
001.txt AC 1 ms 256 KB
002.txt AC 1 ms 256 KB
003.txt AC 1 ms 256 KB
004.txt AC 1 ms 256 KB
005.txt AC 1 ms 256 KB
006.txt AC 1 ms 256 KB
007.txt AC 1 ms 256 KB
008.txt AC 1 ms 256 KB
009.txt AC 1 ms 256 KB
010.txt AC 3 ms 2176 KB
011.txt AC 10 ms 13184 KB
012.txt AC 6 ms 7424 KB
013.txt AC 7 ms 8832 KB
014.txt AC 5 ms 6272 KB
015.txt AC 11 ms 14464 KB
016.txt AC 10 ms 13440 KB
017.txt AC 5 ms 5888 KB
018.txt AC 10 ms 13952 KB
019.txt AC 3 ms 3072 KB
020.txt AC 11 ms 15872 KB
021.txt AC 11 ms 15872 KB
022.txt AC 12 ms 15872 KB
023.txt AC 11 ms 15872 KB
024.txt AC 12 ms 15872 KB
025.txt AC 12 ms 15872 KB
026.txt AC 12 ms 15872 KB
027.txt AC 12 ms 15872 KB
028.txt AC 12 ms 15872 KB
029.txt AC 12 ms 15872 KB
030.txt AC 11 ms 15872 KB
031.txt AC 12 ms 15872 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB
example2.txt AC 1 ms 384 KB