CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel)

Submission #1569016

Source codeソースコード

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

#include <sstream>
#include <algorithm>
#include <iterator>
#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)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int X;
	double P;
	cin >> X >> P;
	if( P == 100 ){
		double ans = (X+1)/2;
		cout << ans << endl;
		return;
	}
	if( X <= 10 ){
		double p = P/100;
		double q = 1-p;
		if( X%2 == 0 ){//Xが偶数
			vector<double> dp(X+10,0);
			dp[0] = 0.0;//距離が0の時の期待値
			int now = 0;
			for(;now<X;now += 2 ){
				dp[now+2] = dp[now] + 1.0/p;
			}
			double ans = dp[X];
			cout << ans << endl;
			return;
		}else{//距離Xが奇数
			vector<double> dp(X+20,0);
			dp[0] = 0.0;
			int now = 0;
			for(;now<X+4; now += 2 ){
				dp[now+2] = dp[now] + 1.0/p;
			}
			double ans = dp[X-1]*p + dp[X+1]*q + 1.0;/////
			cout << ans << endl;
			return;
		}
		return;
	}
	if( X&1 ){//奇数
		double p = P/100;
		double q = 1-p;
		double cnt1 = (X-1)/2;
		double cnt2 = (X+1)/2;
		double res1 = (1.0/p) * cnt1;
		double res2 = (1.0/p) * cnt2; 
		double ans = res1 * p + res2 * q + 1.0;
		cout << ans << endl;
	}else{//偶数
		double p = P/100;
		double q = 1-p;
		double cnt = X/2;//cnt回pを引き当てる。
		//pを1回引くまでの、試行回数の期待値は1/p
		double ans = (1.0/p) * cnt;
		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問題 A - 迷子の高橋君 / Takahashi is Missing!
User nameユーザ名 akarin55
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 700
Source lengthソースコード長 2495 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 256 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask_01_ex1.txt,subtask_03_ex2.txt,subtask_04_ex3.txt
Dataset1 200 / 200 subtask_01_02.txt,subtask_01_03.txt,subtask_01_04.txt,subtask_01_ex1.txt,subtask_02_01.txt,subtask_02_02.txt,subtask_02_03.txt
Dataset2 300 / 300 subtask_01_02.txt,subtask_01_03.txt,subtask_01_04.txt,subtask_01_ex1.txt,subtask_03_01.txt,subtask_03_02.txt,subtask_03_03.txt,subtask_03_04.txt,subtask_03_05.txt,subtask_03_ex2.txt
Dataset3 200 / 200 subtask_01_02.txt,subtask_01_03.txt,subtask_01_04.txt,subtask_01_ex1.txt,subtask_02_01.txt,subtask_02_02.txt,subtask_02_03.txt,subtask_03_01.txt,subtask_03_02.txt,subtask_03_03.txt,subtask_03_04.txt,subtask_03_05.txt,subtask_03_ex2.txt,subtask_04_01.txt,subtask_04_02.txt,subtask_04_03.txt,subtask_04_04.txt,subtask_04_05.txt,subtask_04_06.txt,subtask_04_07.txt,subtask_04_08.txt,subtask_04_09.txt,subtask_04_ex3.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask_01_02.txt AC 1 ms 256 KB
subtask_01_03.txt AC 1 ms 256 KB
subtask_01_04.txt AC 1 ms 256 KB
subtask_01_ex1.txt AC 1 ms 256 KB
subtask_02_01.txt AC 1 ms 256 KB
subtask_02_02.txt AC 1 ms 256 KB
subtask_02_03.txt AC 1 ms 256 KB
subtask_03_01.txt AC 1 ms 256 KB
subtask_03_02.txt AC 1 ms 256 KB
subtask_03_03.txt AC 1 ms 256 KB
subtask_03_04.txt AC 1 ms 256 KB
subtask_03_05.txt AC 1 ms 256 KB
subtask_03_ex2.txt AC 1 ms 256 KB
subtask_04_01.txt AC 1 ms 256 KB
subtask_04_02.txt AC 1 ms 256 KB
subtask_04_03.txt AC 1 ms 256 KB
subtask_04_04.txt AC 1 ms 256 KB
subtask_04_05.txt AC 1 ms 256 KB
subtask_04_06.txt AC 1 ms 256 KB
subtask_04_07.txt AC 1 ms 256 KB
subtask_04_08.txt AC 1 ms 256 KB
subtask_04_09.txt AC 1 ms 256 KB
subtask_04_ex3.txt AC 1 ms 256 KB