Search is not available for this dataset
name
stringlengths 2
88
| description
stringlengths 31
8.62k
| public_tests
dict | private_tests
dict | solution_type
stringclasses 2
values | programming_language
stringclasses 5
values | solution
stringlengths 1
983k
|
---|---|---|---|---|---|---|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>
#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <ctime>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)
const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;
#define int long long
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int x, p;
cin >> x >> p;
ld ans;
int tmp = (x + 1) / 2;
ans = (ld(100) / ld(p)) * ld(tmp);
cout << fixed << setprecision(20) << ans << "\n";
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <stdio.h>
using namespace std;
int x;
double p;
int main(void)
{
cin >> x >> p;
p /= 100;
double ans;
if(x % 2 == 0){
ans = x/2/p;
}
else{
ans = p*(x-1)/2/p + (1-p)*(x+1)/2/p + 1;
}
printf("%.11f\n", ans);
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
struct Precision{
Precision(){
cout<<fixed<<setprecision(12);
}
}precision_beet;
//INSERT ABOVE HERE
signed main(){
int x;
double p;
cin>>x>>p;
p/=100;
double ans=(x&1);
if(x&1){
ans+=p*(1/p)*(x-1)/2;
ans+=(1.-p)*(1/p)*(x+1)/2;
}else{
ans+=(1/p)*x/2;
}
cout<<ans<<endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
is >> p.first >> p.second;
return is;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
for (auto& x : v) {
is >> x;
}
return is;
}
template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
for (auto& x : v) {
os << x << " ";
}
os << "\n";
return os;
}
long double ans(uint64_t x, long double p) {
return (x / 2) / p;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
uint64_t x, P;
cin >> x >> P;
long double p = P / 100.0;
cout << setprecision(9);
if (x % 2 == 1) {
cout << fixed << 1.0 + p * ans(x - 1, p) + (1.0 - p) * ans(x + 1, p);
} else {
cout << fixed << ans(x, p);
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | //xが偶数のとき, 移動方法が定まる(右に移動すればいい)ので簡単.
//xが奇数のとき, 1ターン止まったあと, xが偶数のパターンになる。
//x-1, x+1どちらになっても(最適な)動き方は同じ・不完全情報ゲームより(?)、止まるタイミングは最初にして良いので簡単。
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int x, p;
cin >> x >> p;
double P = p * 0.01;
if (x % 2 == 0) {
printf("%.14f\n", x / (2 * P));
}
else {
double e1 = (x - 1) / (2 * P);
double e2 = (x + 1) / (2 * P);
printf("%.14f\n", P * e1 + (1 - P) * e2 + 1);
}
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
ll ugauss(ll a, ll b) { if (!a) return 0; if (a>0^b>0) return a/b; else return (a+(a>0?-1:1))/b+1; }
ll lgauss(ll a, ll b) { if (!a) return 0; if (a>0^b>0) return (a+(a>0?-1:1))/b-1; else return a/b; }
template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args>
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]"; return o; }
template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]"; return o; }
template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; }
vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; }
template <typename T> istream& operator>>(istream& i, vector<T>& o) { rep(j, o.size()) i >> o[j]; return i;}
template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " ";} return o; }
template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " ";} return o; }
template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " ";} return o; }
template <typename T> unordered_map<T, ll> counter(vector<T> vec){unordered_map<T, ll> ret; for (auto&& x : vec) ret[x]++; return ret;};
void vizGraph(vvll& g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "")<< endl; } ofs << "}" << endl; ofs.close(); system(((string)"dot -T png out.dot >" + filename).c_str()); }
struct timeval start; double sec() { struct timeval tv; gettimeofday(&tv, NULL); return (tv.tv_sec - start.tv_sec) + (tv.tv_usec - start.tv_usec) * 1e-6; }
size_t random_seed; struct init_{init_(){ ios::sync_with_stdio(false); cin.tie(0); gettimeofday(&start, NULL); struct timeval myTime; struct tm *time_st; gettimeofday(&myTime, NULL); time_st = localtime(&myTime.tv_sec); srand(myTime.tv_usec); random_seed = RAND_MAX / 2 + rand() / 2; }} init__;
#define ldout fixed << setprecision(40)
#define EPS (double)1e-14
#define INF (ll)1e18
#define mo (ll)(1e9+7)
int main(void) {
double x, p; cin >> x >> p; p /= 100;
double ret = 0;
if ((ll)(x) % 2 == 0) {
ret = x / 2. / p;
} else {
ret = (x-1.)/2.+(1.-p)*(x+1.)/2./p+1;
}
cout << ldout << ret << endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
#include<iomanip>
using namespace std;
int X;
double p;
double calc(int x)
{
return x/2/p;
}
int main()
{
cin>>X>>p;p/=100;
double ans;
if(X%2==0)ans=calc(X);
else ans=p*calc(X-1)+(1-p)*calc(X+1)+1;
cout<<fixed<<setprecision(16)<<ans<<endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>
#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>
#define cauto const auto&
#else
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;
#define VV(T) vector<vector< T > >
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
v.assign(a, vector<T>(b, t));
}
template <class F, class T>
void convert(const F &f, T &t){
stringstream ss;
ss << f;
ss >> t;
}
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif
#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
void mainmain(){
ll _x;
cin>>_x;
double x=_x;
double p;
cin>>p;
p = p/100;
double ans;
if(_x%2==0){
ans = 1/p*x/2;
}
else{
ans = p*(1/p*(x-1)/2) + (1-p)*(1/p*(x+1)/2);
ans+=1;
}
cout<<ans<<endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout<<fixed<<setprecision(20);
mainmain();
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
#ifdef DEBUG
#define debug(args...) {dbg,args; cerr<<endl;}
#else
#define debug(args...) // Just strip off all debug tokens
#endif
struct debugger
{
template<typename T> debugger& operator , (const T& v)
{
cerr<<v<<" ";
return *this;
}
} dbg;
ld solve(ll b, ld p) {
ld ans;
if (b==0) ans=0;
else ans=b/p;
return ans;
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
cout<<fixed<<setprecision(10);
ll x,pp; cin>>x>>pp;
ld p=(ld)pp/100.0;
ll b=x/2;
if (x&1) {
ld ans=solve(1,p)+(solve(b,p));
cout<<ans<<endl;
}
else {
cout<<solve(b,p)<<endl;
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
long long X, P;
cin >> X >> P;
double ans;
if(X % 2 == 0) ans = 50.0 * X / P;
else ans = 50.0 * (X + 1.0) / P;
cout.precision(15);
cout << ans << endl;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/
double f(ll x, double p) {
return double(x) / p;
}
int main() {
cout.precision(13);
ll x; double p;
cin >> x >> p; p /= 100;
if (x % 2 == 0) {
x /= 2;
cout << f(x, p) << endl;
}
else {
ll y = x / 2;
x = y + 1;
cout << 1+ (f(x, p)* (1-p) + f(y, p)*p) << endl;
}
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>
using namespace std;
#define INF 1000000007
#define LINF (1LL << 62)
typedef long long i64;
typedef pair<i64,i64> P;
i64 n, m;
int main(){
cin >> n >> m;
printf("%.10f\n", (n+n%2)*50.0/m);
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
long long x,p;cin>>x>>p;x=(x+1)/2*100;
cout<<fixed<<setprecision(6)<<x/(double)p<<endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
double solve(int x, double p)
{
if(x%2==1)
return p*solve(x-1, p)+(1.0-p)*solve(x+1, p)+1.0;
x/=2;
return x/p;
}
int main()
{
int x, p;
scanf("%d%d", &x, &p);
printf("%.9f\n", solve(x, p/100.0));
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int MOD = 1e9+7;
signed main(){
int x;
double p;
cin >> x >> p;
cout << fixed << setprecision(7) << (x + 1) / 2 / p * 100.0 << endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
double X;
double P;
int main()
{
cin >> X >> P;
printf("%lf\n" ,50.0 * (X + ((int)X % 2)) / P);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
long long x;
double p;
cin>>x>>p;
if(x%2){cout<<setprecision(20)<<(((double)x+1)/2)/p*100<<endl;}
else{ cout<<setprecision(20)<<(((double)x)/2)/p*100<<endl;}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
void solve(){
int x;
double p;
cin >> x >> p;
p/=100;
cout << (x+1)/2/p << endl;
}
int main(){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(10);
solve();
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif
const int MAXN = 100;
//#define int long long
const int INF = 1e9;
/*
task from atcoder: https://atcoder.jp/contests/cf16-tournament-round2-open/tasks/asaporo_e
*/
void solve(){
int x, p;
cin >> x >> p;
cout << fixed << setprecision(30) <<((ld)(x + x % 2) * 100.0) / ((ld)p * 2.0) << '\n';
}
signed main()
{
#ifdef FILEIO
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long LL;
struct cww{cww(){
ios::sync_with_stdio(false);cin.tie(0);
cout<<fixed;
cout<<setprecision(10);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
for(auto &it:v)is>>it;
return is;
}
double p;
double f(LL x){
x/=2;
return x/p;
}
int main(){
LL x;
cin>>x>>p;
p/=100;
if(x%2)cout<<1+p*f(x-1)+(1-p)*f(x+1)<<endl;
else cout<<f(x)<<endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
signed main(){
int x;
double p;
cin>>x>>p;
p/=100;
double ans;
if(x&1){
ans=(1-p)*(x+1)/2/p+p*1.0*(x-1)/2/p+1;
}
else{
ans=x/2/p;
}
printf("%.20f\n",ans);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<iomanip>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int main(){
ll x,p;cin>>x>>p;
cout<<fixed<<setprecision(10)<<(x+1)/2*100/(double)p<<endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int x;
double p;
cin >> x >> p;
p /= 100.0;
if(x % 2) {
x /= 2;
printf("%.9lf\n",x + (x + 1) / p * (1 - p) + 1);
}
else printf("%.9lf\n",x / 2 / p);
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | java | // package atcoder.other2016.codefestival2016.round2;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int x = in.nextInt();
int p = in.nextInt();
if (p == 100) {
out.println((x + 1) / 2);
} else {
double rate = p / 100.0;
if (x % 2 == 0) {
out.println(String.format("%.9f", solve(rate, x)));
} else {
out.println(String.format("%.9f", 1 + rate * solve(rate, x-1) + (1.0 - rate) * solve(rate, x+1)));
}
}
out.flush();
}
private static double solve(double rate, int x) {
return (1.0d / rate) * (x / 2);
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
private int[] nextInts(int n) {
int[] ret = new int[n];
for (int i = 0; i < n; i++) {
ret[i] = nextInt();
}
return ret;
}
private int[][] nextIntTable(int n, int m) {
int[][] ret = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ret[i][j] = nextInt();
}
}
return ret;
}
private long[] nextLongs(int n) {
long[] ret = new long[n];
for (int i = 0; i < n; i++) {
ret[i] = nextLong();
}
return ret;
}
private long[][] nextLongTable(int n, int m) {
long[][] ret = new long[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ret[i][j] = nextLong();
}
}
return ret;
}
private double[] nextDoubles(int n) {
double[] ret = new double[n];
for (int i = 0; i < n; i++) {
ret[i] = nextDouble();
}
return ret;
}
private int next() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public char nextChar() {
int c = next();
while (isSpaceChar(c))
c = next();
if ('a' <= c && c <= 'z') {
return (char) c;
}
if ('A' <= c && c <= 'Z') {
return (char) c;
}
throw new InputMismatchException();
}
public String nextToken() {
int c = next();
while (isSpaceChar(c))
c = next();
StringBuilder res = new StringBuilder();
do {
res.append((char) c);
c = next();
} while (!isSpaceChar(c));
return res.toString();
}
public int nextInt() {
int c = next();
while (isSpaceChar(c))
c = next();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c-'0';
c = next();
} while (!isSpaceChar(c));
return res*sgn;
}
public long nextLong() {
int c = next();
while (isSpaceChar(c))
c = next();
long sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c-'0';
c = next();
} while (!isSpaceChar(c));
return res*sgn;
}
public double nextDouble() {
return Double.valueOf(nextToken());
}
public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static void debug(Object... o) {
System.err.println(Arrays.deepToString(o));
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
ll x;double p;cin>>x>>p;
double ans;
if(x%2==0){
ans=(100.0/p)*(double)(x/2.0);
}else{
ans=(p/100.0)*((100.0/p)*(double)((x-1.0)/2.0)+1)+((100.0-p)/100.0)*((100.0/p)*(double)(x+1.0)/2.0+1);
}
printf("%.10f\n",ans);
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;
void yes() {cout << "Yes" << endl;}
void no() {cout << "No" << endl;}
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int INF = 1e9 + 9;
const long long LINF = 1e18 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7; //998244353
const double PI = acos(-1);
void solve() {
long long x, p; cin >> x >> p;
cout << fixed << setprecision(6) << (double)((x + 1) / 2 * 100.0 / p) << endl;
}
int main() {
jonathan;
livingston;
solve();
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>
using namespace std;
#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double
ostream& operator<< (ostream &out, const vector<int> &b) {
for (auto k : b) out << k << " ";
return out;
}
istream& operator>> (istream& in, pii& b) {
in >> b.first >> b.second;
return in;
}
ostream& operator<< (ostream& out, const pii& b) {
out << "{" << b.first << ", " << b.second << "}";
return out;
}
template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
#ifdef LOCAL
#define dbg(x) cout << #x << " : " << (x) << "\n";
const int INF = 1e18;
// const int mod = 2600000069;
// const int p = 10;
#else
#define dbg(x) 57
const int INF = 1e18;
// const int mod = 2600000069;
// const int p = 179;
#endif
const ld PI = acos(-1);
#define time clock() / (double) CLOCKS_PER_SEC
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int x, p;
cin >> x >> p;
cout << fixed << setprecision(8);
if (x & 1) {
cout << ((100.0 - p) / 100.0 * (ld)(x + 1) / (ld)p * 100.0 + (ld)p / 100.0 * (ld)(x - 1) / (ld)p * 100.0) / 2.0 + 1.0 << "\n";
} else {
cout << ((ld)x / (ld)p * 100.0) / 2.0 << "\n";
}
}
/*
*/ |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | java |
import java.io.*;
import java.math.*;
import java.util.*;
import static java.util.Arrays.*;
public class Main {
private static final int mod = (int)1e9+7;
final Random random = new Random(0);
final IOFast io = new IOFast();
/// MAIN CODE
public void run() throws IOException {
// int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim());
int TEST_CASE = 1;
while(TEST_CASE-- != 0) {
int x = io.nextInt();
double p = io.nextDouble() / 100;
// E(x) = 1 + p*E(x-1) + (1-p)*E(x)
// E(x) = (p*E(x-1) + 1) / p
// E(x) = E(x-1) + 1 / p
if (x % 2 == 1) {
io.out.printf("%.10f\n", (x + x + 3) / 4 / p);
} else {
io.out.printf("%.10f\n", (x + x + 3) / 4 / p);
}
}
}
static double pow(double n, long r) {
double res = 1;
for(; r != 0; r >>>= 1, n = n * n) {
if((r&1) == 1) {
res = res * n;
}
}
return res;
}
/// TEMPLATE
static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); }
static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); }
static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; }
static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; }
void printArrayLn(int[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); }
void printArrayLn(long[] xs) { for(int i = 0; i < xs.length; i++) io.out.print(xs[i] + (i==xs.length-1?"\n":" ")); }
static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); }
void main() throws IOException {
// IOFast.setFileIO("rle-size.in", "rle-size.out");
try { run(); }
catch (EndOfFileRuntimeException e) { }
io.out.flush();
}
public static void main(String[] args) throws IOException { new Main().main(); }
static class EndOfFileRuntimeException extends RuntimeException {
private static final long serialVersionUID = -8565341110209207657L; }
static
public class IOFast {
private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
private PrintWriter out = new PrintWriter(System.out);
void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); }
void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); }
void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); }
private static int pos, readLen;
private static final char[] buffer = new char[1024 * 8];
private static char[] str = new char[500*8*2];
private static boolean[] isDigit = new boolean[256];
private static boolean[] isSpace = new boolean[256];
private static boolean[] isLineSep = new boolean[256];
static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; }
public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; }
public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; }
public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; }
public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } }
int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; }
int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; }
public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); }
public String nextString() throws IOException { return new String(next()); }
public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); }
// public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; }
public double nextDouble() throws IOException { return Double.parseDouble(nextString()); }
public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; }
public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; }
public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; }
public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; }
public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; }
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | java | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
static InputStream is;
static PrintWriter out;
static String INPUT = "";
static void solve()
{
int x = ni(), p = ni();
/*
* 1/p*(x/2)
*/
out.printf("%.14f\n", (double)((x+1)/2)/(p/100.));
}
public static void main(String[] args) throws Exception
{
long S = System.currentTimeMillis();
is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
solve();
out.flush();
long G = System.currentTimeMillis();
tr(G-S+"ms");
}
private static boolean eof()
{
if(lenbuf == -1)return true;
int lptr = ptrbuf;
while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;
try {
is.mark(1000);
while(true){
int b = is.read();
if(b == -1){
is.reset();
return true;
}else if(!isSpaceChar(b)){
is.reset();
return false;
}
}
} catch (IOException e) {
return true;
}
}
private static byte[] inbuf = new byte[1024];
static int lenbuf = 0, ptrbuf = 0;
private static int readByte()
{
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf){
ptrbuf = 0;
try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
if(lenbuf <= 0)return -1;
}
return inbuf[ptrbuf++];
}
private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
// private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }
private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
private static double nd() { return Double.parseDouble(ns()); }
private static char nc() { return (char)skip(); }
private static String ns()
{
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b))){
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
private static char[] ns(int n)
{
char[] buf = new char[n];
int b = skip(), p = 0;
while(p < n && !(isSpaceChar(b))){
buf[p++] = (char)b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
private static char[][] nm(int n, int m)
{
char[][] map = new char[n][];
for(int i = 0;i < n;i++)map[i] = ns(m);
return map;
}
private static int[] na(int n)
{
int[] a = new int[n];
for(int i = 0;i < n;i++)a[i] = ni();
return a;
}
private static int ni()
{
int num = 0, b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static long nl()
{
long num = 0;
int b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
int x;
double p;
cin >> x >> p;
p/=100.0;
if(1){
cout << fixed << setprecision(10) << (x+1)/2/p << endl;
}
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
using namespace std;
int main(){
double p;
lint x;
cin>>x>>p;
double ans;
double c;
if(p==100){
if(x%2==0)
cout<<x/2;
else
cout<<(x+1)/2;
return 0;
}
if(x%2==1)
x++;
c=-1*p/100+1*(100-p)/100;
ans=x/(1-c);
cout<< fixed << setprecision(8) << ans;
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | // #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}
int x , p;
int main(){
scanf("%d%d",&x,&p);
db ans = 0.;
if(x & 1) ans = 1 + ((x - 1) / 2 + (100. - p) / p * (x + 1) / 2);
else ans = 100. / p * x / 2;
printf("%.12f\n",ans);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
double calc(int x,double pp){
return ((double)x/2.0)/pp;
}
int main(){
int x;
int p;
cin >> x >> p;
double pp = (double)p/100.0;
if(x%2==0){
cout << fixed << setprecision(10) << calc(x,pp) << endl;
}else{
cout << fixed << setprecision(10) << 1.0+pp*calc(x-1,pp)+(1.0-pp)*calc(x+1,pp) << endl;
}
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | python3 | x = int(input())
p = int(input())
print("%.016f\n" % ((((x+(x%2))/2)*100/p))) |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | # include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq) (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw) (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe) transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr) transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy) for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu) FOR(i,0,upupu)
# define INIT std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)
double n;
double p;
int main() {
cin >> n >> p;
p /= 100.0;
cout << fixed << setprecision(13) << ceil(n / 2) / p << endl;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#include <random>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif
const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
return in >> a.first >> a.second;
}
template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}
template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
out << "[";
fori (i, a.size())
out << a[i] << vector<string>{", ", "] "}[i + 1 == a.size()];
return out;
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
freopen("input", "r", stdin);
//freopen("output.txt", "w", stdout);
clock_t start = clock();
#endif
cout << setprecision(12) << fixed;
smain();
#ifdef RUS_HOME
cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) / CLOCKS_PER_SEC << endl;
#endif
return 0;
}
const int MOD=1e9+7,N=1e5+1,M=4e5+100,oo=1e9;
void smain() {
int x,p;
cin>>x>>p;
cout<<(ld)((x/2+x%2)*100)/p;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
long x,p;cin>>x>>p;
cout<<fixed<<setprecision(10)<<50.0*(x+x%2)/p;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;
template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
int main() {
ll x, p;
cin >> x >> p;
ll k = (x+1)/2;
printf("%.15Lf", (100/(long double)p)*k);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int X, P; cin >> X >> P;
int a = (X + 1) / 2;
double p = P / 100.0;
cout << fixed << setprecision(9) << 1 / p * a << endl;
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | python3 | x=int(input())
p=int(input())/100
print((x+1)//2 * 1 / p) |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// 1ターン分プラスして,
// dp_x=1+dp_(x-2)*P/100+dp_x*(100-p)/100
// dp_x=dp_(x-2)+100/p
int main(){
ll x; cin>>x;
double p; cin>>p;
if(x%2) x++;
cout<<setprecision(15);
cout<<x/2*100/p<<endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)
int x,p;
double solve(int n){
return 100.0 * n / p;
}
int main(){
scanf("%d%d" , &x , &p);
if(p == 100){
printf("%d\n" , (x+1) / 2);
} else if(x%2==0){
printf("%.9f\n" , solve(x/2));
} else {
printf("%.9f\n" , 1.0 + solve(x/2)*0.01*p + solve(x/2+1)*0.01*(100-p));
}
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
ll x;
cin>>x;
double p;
cin>>p;
if(abs(p-100)<0.01){
x++;
cout << x/2 << endl;
return 0;
}
p/=100.0;
if(x%2==0){
cout << (double)x/2.0/p << "\n";
}
else{
x++;
cout << (double)x/2.0/p << "\n";
}
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int num,pr;
scanf("%d%d",&num,&pr);
if(num%2==1)num++;
printf("%lf\n",(double)num/(1.0-double(100-pr)/double(100)+double(pr)/double(100)));
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include "bits/stdc++.h"
#include <unordered_set>
#define _CRT_SECURE_NO_WARNINGS
#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)
#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())
using namespace std;
const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };
using LL = long long int;
using LD = long double;
const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int x, p;
cin >> x >> p;
double ans = (x + 1) / 2 * 100.0 / p;
printf("%.7lf\n", ans);
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#include <random>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define char ll
//#define double ld
typedef vector<char> vc;
typedef vector <vc> vvc;
typedef vector <vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii> vpi;
typedef vector <vi> vvi;
typedef vector <vvi> vvvi;
typedef vector<short> vs;
typedef vector <vs> vvs;
typedef vector <vvs> vvvs;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef vector <vvl> vvvl;
typedef vector <ld> vld;
typedef vector <vld> vvld;
typedef vector <vvld> vvvld;
typedef vector <string> vst;
typedef vector <vst> vvst;
typedef pair<ld, ld> pld;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;
#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif
const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template<class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
return out << "{" << a.first << ", " << a.second << "}";
}
template<class T0, class T1>
inline istream &operator>>(istream &in, pair<T0, T1> &a) {
return in >> a.first >> a.second;
}
template<class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}
template<class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}
template<class T>
inline ostream &operator<<(ostream &out, vector <T> &a) {
out << "[";
fori (i, a.size())out << a[i] << vector < string > {", ", "] "}[i + 1 == a.size()];
return out;
}
void smain();
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef MAX_HOME
freopen("input.txt", "r", stdin);
clock_t start = clock();
#endif
#ifdef HK_CUP
freopen("finput.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cout << setprecision(12) << fixed;
smain();
#ifdef MAX_HOME
#ifndef HK_CUP
cout << "\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif
#endif
return 0;
}
ld f(ll x, ld p) {
return x / p;
}
void smain() {
ll x;
ld p;
cin >> x >> p;
p /= 100;
ld ans = 0;
if (x & 1) {
ans = 1 + p * f((x - 1) / 2, p) + (1 - p) * f((x + 1) / 2, p);
} else {
ans = f(x / 2, p);
}
cout << ans;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int x, p; cin >> x >> p;
x = (x + 1) / 2;
cout << fixed << setprecision(12) << 100. / p * x << endl;
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
int main() {
int x;
double p;
cin >> x >> p;
x = (x+1)/2;
printf("%.10f\n", x/(p/100));
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
using namespace std;
int main() {
int x, p;
cin >> x >> p;
if (p == 100) {
int tim = (x+1) / 2;
cout << tim << endl;
return 0;
}
double pp = p / 100.0;
// 奇数
if (x % 2) {
printf("%.14f\n", (double)(1 - pp) / pp + 1 + (double)(x/2) / pp);
}
else
printf("%.14f\n", (double)(x/2) / pp);
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include <math.h>
#include<algorithm>
// #include <boost/multiprecision/cpp_int.hpp>
#include<functional>
#define int long long
#define inf 1000000007
#define pa pair<int,int>
#define ll long long
#define pal pair<double,pa>
#define ppa pair<pa,int>
#define ppap pair<int,pa>
#define ssa pair<string,int>
#define mp make_pair
#define pb push_back
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
public:
double x,y;
Point(double x=0,double y=0):x(x),y(y) {}
Point operator + (Point p) {return Point(x+p.x,y+p.y);}
Point operator - (Point p) {return Point(x-p.x,y-p.y);}
Point operator * (double a) {return Point(x*a,y*a);}
Point operator / (double a) {return Point(x/a,y/a);}
double absv() {return sqrt(norm());}
double norm() {return x*x+y*y;}
bool operator < (const Point &p) const{
return x != p.x ? x<p.x: y<p.y;
}
bool operator == (const Point &p) const{
return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
}
};
typedef Point Vector;
struct Segment{
Point p1,p2;
};
double dot(Vector a,Vector b){
return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
return a.x*b.y-a.y*b.x;
}
class pa3{
public:
int x,y,z;
pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {}
bool operator < (const pa3 &p) const{
if(x!=p.x) return x<p.x;
if(y!=p.y) return y<p.y;
return z<p.z;
//return x != p.x ? x<p.x: y<p.y;
}
bool operator > (const pa3 &p) const{
if(x!=p.x) return x>p.x;
if(y!=p.y) return y>p.y;
return z>p.z;
//return x != p.x ? x<p.x: y<p.y;
}
bool operator == (const pa3 &p) const{
return x==p.x && y==p.y && z==p.z;
}
bool operator != (const pa3 &p) const{
return !( x==p.x && y==p.y && z==p.z);
}
};
bool parareru(Point a,Point b,Point c,Point d){
// if(abs(cross(a-b,d-c))<EPS)cout<<"dd "<<cross(a-b,d-c)<<endl;
return abs(cross(a-b,d-c))<EPS;
}
double distance_ls_p(Point a, Point b, Point c) {
if ( dot(b-a, c-a) < EPS ) return (c-a).absv();
if ( dot(a-b, c-b) < EPS ) return (c-b).absv();
return abs(cross(b-a, c-a)) / (b-a).absv();
}
bool is_intersected_ls(Segment a,Segment b) {
if(a.p1==b.p1||a.p2==b.p1||a.p1==b.p2||a.p2==b.p2) return false;
if(parareru((a.p2),(a.p1),(a.p1),(b.p2))&¶reru((a.p2),(a.p1),(a.p1),(b.p1))){
// cout<<"sss"<<endl;
if(dot(a.p1-b.p1,a.p1-b.p2)<EPS) return true;
if(dot(a.p2-b.p1,a.p2-b.p2)<EPS) return true;
if(dot(a.p1-b.p1,a.p2-b.p1)<EPS) return true;
if(dot(a.p1-b.p2,a.p2-b.p2)<EPS) return true;
return false;
}
else return ( cross(a.p2-a.p1, b.p1-a.p1) * cross(a.p2-a.p1, b.p2-a.p1) < EPS ) && ( cross(b.p2-b.p1, a.p1-b.p1) * cross(b.p2-b.p1, a.p2-b.p1) < EPS );
}
double segment_dis(Segment a,Segment b){
if(is_intersected_ls(a,b))return 0;
double r=distance_ls_p(a.p1, a.p2, b.p1);
r=min(r,distance_ls_p(a.p1, a.p2, b.p2));
r=min(r,distance_ls_p(b.p1, b.p2, a.p2));
r=min(r,distance_ls_p(b.p1, b.p2, a.p1));
return r;
}
Point intersection_ls(Segment a, Segment b) {
Point ba = b.p2-b.p1;
double d1 = abs(cross(ba, a.p1-b.p1));
double d2 = abs(cross(ba, a.p2-b.p1));
double t = d1 / (d1 + d2);
return a.p1 + (a.p2-a.p1) * t;
}
string itos( int i ) {
ostringstream s ;
s << i ;
return s.str() ;
}
int gcd(int v,int b){
if(v>b) return gcd(b,v);
if(v==b) return b;
if(b%v==0) return v;
return gcd(v,b%v);
}
double distans(double x1,double y1,double x2,double y2){
double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
return sqrt(rr);
}
/*
int pr[100010];
//int inv[100010];
*/
int beki(int wa,int rr,int warukazu){
if(rr==0) return 1ll;
if(rr==1) return wa%warukazu;
if(rr%2==1) return (beki(wa,rr-1,warukazu)*wa)%warukazu;
int zx=beki(wa,rr/2,warukazu);
return (zx*zx)%warukazu;
}
// cin.tie(0);
//ios::sync_with_stdio(false);
/*
void gya(){
pr[0]=1;
for(int i=1;i<100010;i++){
pr[i]=(pr[i-1]*i)%inf;
}
for(int i=0;i<100010;i++) inv[i]=beki(pr[i],inf-2);
}
*/
//sort(ve.begin(),ve.end(),greater<int>());
//----------------kokomade tenpure------------
//vector<double> ans(100000000),ans2(100000000);
int par[200100],ranks[200100],kosuu[200100];
void shoki(int n){
for(int i=0;i<n;i++){
par[i]=i;
ranks[i]=0;
kosuu[i]=1;
}
}
int root(int x){
return par[x]==x ? x : par[x]=root(par[x]);
}
bool same(int x,int y){
return root(x)==root(y);
}
void unite(int x,int y){
x=root(x);
y=root(y);
int xx=kosuu[x],yy=kosuu[y];
if(x==y) return;
if(ranks[x]<ranks[y]){
par[x]=y;
kosuu[y]=yy+xx;
}
else {
par[y]=x;
if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1;
kosuu[x]=yy+xx;
}
return;
}
vector<int> ve;
int ans[100020];
int w[100020];
int x[100020];
int n,l,t;
int f(int r){
if(r>=0){
return r%n;
}
int rr=-r;
int g=rr/n+1;
rr-=g*n;
return f(-rr);
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int x;
double p;
cin>>x>>p;
p/=100.0;
x=(x+1)/2;
printf("%.10lf\n",x/p);
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
int main () {
long long x,p;
double ans;
cin >> x >> p;
if (x % 2 == 0) {
x /= 2;
ans = x;
ans *= 100;
ans /= p;
}
else {
x /= 2;
ans = x*p + (x+1)*(100-p);
ans /= p;
ans += 1;
}
cout << fixed << setprecision(10) << ans << endl;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
double x,p;cin>>x>>p;
int y=x;
double iti=(100-2*p)/(double)100;
if((int)y%2==1)x+=iti;
double ans=x/(1-iti);
if((int)y%2==1){
ans+=1.0;
}
cout<<fixed<<setprecision(12)<<ans<<endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
void solve() {
int X, P;
cin >> X >> P;
double p = P / 100.0;
auto f = [&](int x) {
return x / (2 * p);
};
if (X % 2 == 0) {
cout << f(X) << endl;
} else {
cout << 1 + f(X - 1)*p + f(X + 1)*(1 - p) << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(15);
solve();
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | python3 | N = int(input())
M = int(input())
if N%2:
print(1 + (N-1) / 2 + (100 - M) * (N+1) /2 / M)
else:
print(N * 50 / M) |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;
const double eps = 1e-6;
template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
const int64 mod = 1e9+7;
double res = 0;
double P;
double E(int64 x){
double num = 1/P;
return num*x/2;
}
int main(void){
int64 x;
cin >> x >> P;
P /= 100;
if(x%2){
res = 1;
res += E(x-1)*P;
res += E(x+1)*(1-P);
}else{
res += E(x);
}
cout << fixed << setprecision(10) << res << endl;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
long long x;
cin >> x;
double p;
cin >> p;
if (p == 100) {
cout << x / 2 << endl;
return 0;
}
p /= 100.0;
if (x % 2 == 0) {
cout << x / 2.0 / p << "\n";
} else {
x++;
cout << x / 2.0 / p + 1 << "\n";
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int x, p;
int main() {
cin >> x >> p;
cout << x / 2 + 1 << endl;
return (0);
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-8;
int main() {
long long x, p;
cin >> x >> p;
cout << (x + 1) / 2 << endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using double = long double;
const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
ll X,P;
const int MAX_TURN = 2000;
const int MAX_POS = 100;
double dp[MAX_TURN][MAX_POS][MAX_POS];
bool visited[MAX_TURN][MAX_POS][MAX_POS];
//map<tuple<int, int, int>, double> dp;
double memo(int turn, int pos_ao, int pos_cho){
if (pos_ao == pos_cho){
return turn;
}
if (turn >= MAX_TURN or pos_ao < 0 or pos_ao >= MAX_POS or pos_cho < 0 or pos_cho >= MAX_POS){
return INF;
}
double pro = (double) P / 100;
if (visited[turn][pos_ao][pos_cho]){
return dp[turn][pos_ao][pos_cho];
}
visited[turn][pos_ao][pos_cho] = true;
//cout << turn << " " << pos_ao << " " << pos_cho << endl;
double result = INF;
//pre
result = min(result, memo(turn + 1, pos_ao - 1, pos_cho - 1) * pro + memo(turn + 1, pos_ao - 1, pos_cho + 1) * (1 - pro));
//stop
result = min(result, memo(turn + 1, pos_ao, pos_cho - 1) * pro + memo(turn + 1, pos_ao, pos_cho + 1) * (1 - pro));
//next
result = min(result, memo(turn + 1, pos_ao + 1, pos_cho - 1) * pro + memo(turn + 1, pos_ao + 1, pos_cho + 1) * (1 - pro));
return dp[turn][pos_ao][pos_cho] = result;
}
int main(){
cin >> X >> P;
if (X > 10)return 0;
int geta = MAX_POS / 2;
double result = memo(0, geta, X + geta);
printf("%.20lf\n", result);
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | python3 | sx = input()
sp = input()
x = int(sx)
p = int(sp)
ret = 0
e = 0
cnt = x % 2
if p == 100:
ret = int(x / 2) + cnt
print(ret) |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll X, P;
const int MAX_TURN = 300;
const int MAX_POS = 200;
double dp[MAX_TURN][MAX_POS][MAX_POS];
bool visited[MAX_TURN][MAX_POS][MAX_POS];
double memo(int turn, int pos_ao, int pos_cho) {
if (pos_ao == pos_cho) {
return turn;
}
if (turn >= MAX_TURN or pos_ao < 0 or pos_ao >= MAX_POS or pos_cho < 0 or
pos_cho >= MAX_POS) {
return INF;
}
double pro = (double)P / 100;
if (visited[turn][pos_ao][pos_cho]) {
return dp[turn][pos_ao][pos_cho];
}
visited[turn][pos_ao][pos_cho] = true;
double result = INF;
result = min(result, memo(turn + 1, pos_ao - 1, pos_cho - 1) * pro +
memo(turn + 1, pos_ao - 1, pos_cho + 1) * (1 - pro));
result = min(result, memo(turn + 1, pos_ao, pos_cho - 1) * pro +
memo(turn + 1, pos_ao, pos_cho + 1) * (1 - pro));
result = min(result, memo(turn + 1, pos_ao + 1, pos_cho - 1) * pro +
memo(turn + 1, pos_ao + 1, pos_cho + 1) * (1 - pro));
return dp[turn][pos_ao][pos_cho] = result;
}
int main() {
cin >> X >> P;
if (X > 10) return 0;
int geta = 100;
double result = memo(0, geta, X + geta);
printf("%.20lf\n", result);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
long long x, p;
int main() {
cin >> x >> p;
if (p != 100) {
return 1;
}
if (x % 2 == 0) {
cout << x / 2 << endl;
} else {
cout << x / 2 + 1 << endl;
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template <class T>
constexpr T INF() {
return ::std::numeric_limits<T>::max();
}
template <class T>
constexpr T HINF() {
return INF<T>() / 2;
}
template <typename T_char>
T_char TL(T_char cX) {
return tolower(cX);
};
template <typename T_char>
T_char TU(T_char cX) {
return toupper(cX);
};
const int vy[] = {-1, -1, -1, 0, 1, 1, 1, 0},
vx[] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int popcnt(unsigned long long n) {
int cnt = 0;
for (int i = 0; i < 64; i++)
if ((n >> i) & 1) cnt++;
return cnt;
}
int d_sum(LL n) {
int ret = 0;
while (n > 0) {
ret += n % 10;
n /= 10;
}
return ret;
}
int d_cnt(LL n) {
int ret = 0;
while (n > 0) {
ret++;
n /= 10;
}
return ret;
}
LL gcd(LL a, LL b) {
if (b == 0) return a;
return gcd(b, a % b);
};
LL lcm(LL a, LL b) {
LL g = gcd(a, b);
return a / g * b;
};
#pragma warning(disable : 4996)
double n;
double p;
int main() {
cin >> n >> p;
p /= 100.0;
cout << fixed << setprecision(13) << (n + 1) / 2 / p << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
ifstream ifs("input");
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
const double PI = (1 * acos(0.0));
const double INF = 1e9;
const double EPS = 1e-9;
const double mod = 1e9 + 7;
int main() {
int x, p;
ifs >> x >> p;
printf("%.7lf", ceil(x / 2.0) * (100.0 / p));
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <stdio.h>
int main(void) {
int a, b;
scanf("%d%d", &x, &p);
printf("%.12f", (double)((x + 1) / 2) * 100.0 / (double)p);
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, p;
double ans;
cin >> x >> p;
if (x % 2 == 0) {
x /= 2;
ans = x;
ans *= 100;
ans /= p;
} else {
x /= 2;
ans = x * p + (x + 1) * (100 - p);
ans /= p;
ans += 1;
}
cout << fixed << setprecision(10) << ans << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x;
int p;
cin >> x >> p;
cout << (x + 1) / 2 << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, p;
cin >> n >> p;
cout << (n % 2 ? 100.0 / p * (n / 2 + 1) : 100.0 / p * (n / 2)) << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
long long x;
cin >> x;
double y = x;
double p;
cin >> p;
if (abs(p - 100) < 0.01) {
x++;
cout << x / 2 << endl;
return 0;
}
p /= 100.0;
if (x % 2 == 0) {
cout << y / 2.0 / p << "\n";
} else {
y++;
cout << y / 2.0 / p + 1 << "\n";
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int x, p;
cin >> x >> p;
cout << (x + 1) / 2 << endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int X;
double p;
double calc(int x) {
double ret = 0;
double pp = 1, np = 1;
for (int i = 0; i < x / 2; i++) pp *= p;
double comb = 1;
for (long k = x / 2; k < 1e6; k++) {
ret += k * pp * np * comb;
np *= 1 - p;
comb *= k;
comb /= k - x / 2 + 1;
}
return ret;
}
int main() {
cin >> X >> p;
p /= 100;
double ans;
if (X % 2 == 0)
ans = calc(X);
else
ans = p * calc(X - 1) + (1 - p) * calc(X + 1) + 1;
cout << fixed << setprecision(16) << ans << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T> >;
int main() {
int x, p;
cin >> x;
cin >> p;
if (p == 100) {
double ans = (x + 1) / 2;
printf("%.10f\n", ans);
}
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
double p;
long long int x;
cin >> x >> p;
double ans;
double c;
if (p == 100) {
if (x % 2 == 0)
cout << x / 2;
else
cout << (x + 1) / 2;
return 0;
}
c = -1 * p / 100 + 1 * (100 - p) / 100;
ans = x / (1 - c);
cout << fixed << setprecision(8) << ans;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int x, p;
cin >> x >> p;
if (p != 100) {
exit(0);
}
cout << 1.0 * ((x + 1) / 2) << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp |
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
if (lhs > rhs) {
lhs = rhs;
return true;
}
return false;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
if (lhs < rhs) {
lhs = rhs;
return true;
}
return false;
}
// [l, r) from l to r
struct range {
struct itr {
int i;
constexpr itr(int i_): i(i_) { }
constexpr void operator ++ () { ++i; }
constexpr int operator * () const { return i; }
constexpr bool operator != (itr x) const { return i != x.i; }
};
const itr l, r;
constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
constexpr itr begin() const { return l; }
constexpr itr end() const { return r; }
};
// [l, r) from r to l
struct revrange {
struct itr {
int i;
constexpr itr(int i_): i(i_) { }
constexpr void operator ++ () { --i; }
constexpr int operator * () const { return i; }
constexpr bool operator != (itr x) const { return i != x.i; }
};
const itr r, l;
constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
constexpr itr begin() const { return r; }
constexpr itr end() const { return l; }
};
int main() {
int X, p;
std::cin >> X >> p;
double P = p / 100.0L;
std::cout << ((X + 1) / 2) / P << '\n';
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
cout.precision(20);
long long x;
long double p, ans;
cin >> x >> p;
ans = (x / 2) * 100 / p;
if (x % 2) {
ans += min((200 - p) / (100 - p), 100 / p);
}
cout << ans << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int in() {
int x;
scanf("%d", &x);
return x;
}
long long lin() {
long long x;
scanf("%lld", &x);
return x;
}
long long MOD = 1e9 + 7;
int main() {
long long x = in();
long long p = in();
long long ans = 0;
if (x % 2) x++;
x /= 2;
cout << (double)((double)(x / (double)p * 100.0));
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
long long int dy[] = {0, 0, 1, -1};
long long int dx[] = {1, -1, 0, 0};
long long int const MOD = 1000000007;
namespace std {
bool operator<(const complex<double>& a, const complex<double>& b) {
return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
}
} // namespace std
signed main() {
long long int x, p;
cin >> x >> p;
cout << fixed << setprecision(10) << (x - 1) / 2 / 1.0 + 1 << endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
class TaskA {
public:
void solve(std::istream& in, std::ostream& out) {
int x, p;
in >> x >> p;
out << (x + 1) / 2;
}
};
int main() {
std::ios_base::sync_with_stdio(false);
TaskA solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
in.tie(nullptr);
out << std::fixed;
out.precision(20);
solver.solve(in, out);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
const int INF = 1 << 29;
const long double EPS = 1e-9;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll X, P;
const int MAX_TURN = 1000;
const int MAX_POS = 100;
long double dp[MAX_TURN][MAX_POS][MAX_POS];
bool visited[MAX_TURN][MAX_POS][MAX_POS];
long double memo(int turn, int pos_ao, int pos_cho) {
if (pos_ao == pos_cho) {
return turn;
}
if (turn >= MAX_TURN or pos_ao < 0 or pos_ao >= MAX_POS or pos_cho < 0 or
pos_cho >= MAX_POS) {
return INF;
}
long double pro = (long double)P / 100;
if (visited[turn][pos_ao][pos_cho]) {
return dp[turn][pos_ao][pos_cho];
}
visited[turn][pos_ao][pos_cho] = true;
long double result = INF;
result = min(result, memo(turn + 1, pos_ao - 1, pos_cho - 1) * pro +
memo(turn + 1, pos_ao - 1, pos_cho + 1) * (1 - pro));
result = min(result, memo(turn + 1, pos_ao, pos_cho - 1) * pro +
memo(turn + 1, pos_ao, pos_cho + 1) * (1 - pro));
result = min(result, memo(turn + 1, pos_ao + 1, pos_cho - 1) * pro +
memo(turn + 1, pos_ao + 1, pos_cho + 1) * (1 - pro));
return dp[turn][pos_ao][pos_cho] = result;
}
int main() {
cin >> X >> P;
if (X > 10) return 0;
int geta = MAX_POS / 2;
long double result = memo(0, geta, X + geta);
printf("%.20Lf\n", result);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int64_t inf64 = 1e18;
const double eps = 1e-9;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
void solve() {
int x, p;
cin >> x >> p;
if (p != 100) return;
if (x % 2 == 0) {
cout << x / 2 << endl;
} else {
cout << x / 2 + 1 << endl;
}
}
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(10);
solve();
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
cout.precision(20);
long long x;
long double p, ans;
cin >> x >> p;
if (x % 2 == 0) {
cout << (50 * x) / p << endl;
} else {
ans = (x / 2) * 100 / p;
if (p <= 38) {
cout << ans + (200 - p) / (100 - p) << endl;
} else {
cout << ans + 100 / p << endl;
}
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int x, p;
cin >> x >> p;
if (p != 100) {
exit(0);
}
cout << (x + 1) / 2. << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | /*** Template Begin ***/
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
auto init_ = [] {
std::ios_base::sync_with_stdio(false);
std::cout << std::fixed;
return 0;
}();
template <typename T>
inline T in() {
T x;
std::cin >> x;
return x;
}
template <typename T>
inline void in(T &x) {
std::cin >> x;
}
template <typename T, typename... Ts>
inline void in(T &t, Ts &... ts) {
std::cin >> t;
in(ts...);
}
template <typename T, typename U = std::vector<T>>
inline U vin(int n) {
U v(n);
for (int i = 0; i < n; ++i) {
std::cin >> v[i];
}
return v;
}
template <typename T, typename U = std::vector<T>, typename V = std::vector<U>>
inline V vin(int h, int w) {
V vv(h, U(w));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
std::cin >> vv[i][j];
}
}
return vv;
}
template <typename T>
inline void out(const T &x) {
std::cout << x << std::endl;
}
template <char delimiter = ' ', typename T, typename... Ts>
inline void out(const T &t, const Ts &... ts) {
std::cout << t << delimiter;
out(ts...);
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int n) {
for (int i = 0; i < n; ++i) {
if (i) std::cout << delimiter;
std::cout << v[i];
}
std::cout << std::endl;
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int h, int w) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (j) std::cout << delimiter;
std::cout << v[i][j];
}
std::cout << std::endl;
}
}
template <typename T, size_t D>
struct multi_vector_type {
using type = std::vector<typename multi_vector_type<T, D - 1>::type>;
};
template <typename T>
struct multi_vector_type<T, 1> {
using type = std::vector<T>;
};
template <typename T>
struct multi_vector_type<T, 0> {
using type = T;
};
template <typename T, size_t D>
using multi_vector = typename multi_vector_type<T, D>::type;
template <typename T, size_t D, class = typename std::enable_if<D == 0>::type>
T make_vector(const T &val = T()) {
return val;
}
template <typename T, size_t D = 1, typename... Ts,
class = typename std::enable_if<D != 0>::type>
multi_vector<T, D> make_vector(size_t n, Ts &&... args) {
return multi_vector<T, D>(n, make_vector<T, D - 1>(args...));
}
using namespace std;
#define USING_BOOST
#ifdef USING_BOOST
#include <boost/range.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/irange.hpp>
inline auto rep(int begin, int end) {
if (begin > end) {
return boost::irange(0, 0);
} else {
return boost::irange(begin, end);
}
}
inline auto rep(int begin, int end, int step) {
if ((step > 0 && begin > end) || (step < 0 && begin < end)) {
return boost::irange(0, 0, step);
} else {
return boost::irange(begin, end, step);
}
}
#endif
#define USING_NAMESPACE
#ifdef USING_NAMESPACE
using namespace std;
#ifdef USING_BOOST
using namespace boost;
using namespace boost::adaptors;
#endif
#endif
/*** Template End ***/
int main() {
int64_t x, p;
in(x, p);
if (p == 100) {
if (x % 2 == 0) {
out(x / 2);
} else {
out(x / 2 + 1);
}
} else {
assert(false);
}
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
const double EPS = 1e-11;
double pq[2521][2521];
int main() {
long long x;
int _p;
cin >> x >> _p;
if (x % 2 == 1) x++;
double p = (double)_p / 100.0;
double q = 1.0 - p;
pq[0][0] = 1.0;
for (int i = 0; i < (int)(2520); ++i)
for (int j = 0; j < (int)(2520); ++j) {
pq[i + 1][j] += pq[i][j] * p;
pq[i][j + 1] += pq[i][j] * q;
}
const int T = 100;
int mn = max(0ll, x - T);
double ans = 0.0;
for (int y = (int)(mn); y < (int)(x); ++y) {
long long tak = y;
long long ao = x - y;
if (tak % 2 != ao % 2) continue;
if (tak < ao) continue;
long long a = x / 2;
long long b = (2 * y - x) / 2;
ans += pq[a][b] * y;
}
for (int y = (int)(x); y < (int)(x + T); ++y) {
if (y % 2 == 1) continue;
long long a = y / 2;
cout << "pq[a][a]"
<< ": " << pq[a][a] << endl;
ans += pq[a][a] * y;
}
printf("%.10lf\n", ans);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
ll x;
cin>>x;
double p;
cin>>p;
if(p==100){
x++
cout << x/2 << endl;
return 0;
}
p/=100.0;
if(x%2==0){
cout << x/2.0/p << "\n";
}
else{
x++;
cout << x/2.0/p + 1 << "\n";
}
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> p) {
return out << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
out << "{";
for (int i = (0); i < (v.size()); i++) out << v[i] << ", ";
return out << "}" << endl;
}
int main() {
int x, p;
cin >> x >> p;
double ans = 0;
cout << (x + 1) / 2 << endl;
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, p1;
cin >> x >> p1;
double p = p1 / 100.0;
if (x % 2) x++;
x /= 2;
cout << ((double)x) / p << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
template <class S, class T>
istream& operator>>(istream& is, pair<S, T>& p) {
return is >> p.first >> p.second;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const long long MOD = 1e9 + 7;
double C[1010][1010];
int main() {
long long x, p;
cin >> x >> p;
if (p == 100) {
cout << (x + 1) / 2 << endl;
return 0;
}
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
float X;
float rad;
float ans;
int main() {
cin >> X >> rad;
if (rad == 100) {
cout << (int)(X + 1) / 2 << "\n";
}
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | import Control.Monad
import Control.Applicative
main :: IO ()
main = do
x <- readLn
getLine
print $ (x+1)`div`2 |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
struct Initializer {
Initializer() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
}
} initializer;
int main() {
int x, p;
cin >> x >> p;
if (p == 100) {
cout << (x + 1) / 2 << endl;
return 0;
}
if (x > 10) exit(-1);
double res = 0;
vector<double> dp(12), dp2;
dp[x] = 1;
if (x % 2) {
dp[x - 1] = p / 100.0;
dp[x + 1] = (100 - p) / 100.0;
}
for (int i = x % 2; i < 100000; ++i) {
res += i * dp[0];
dp2.clear();
dp2.resize(12);
for (uint j = 2; j < dp.size(); ++j) {
dp2[j - 2] += dp[j] * p / 100;
dp2[j] += dp[j] * (100 - p) / 100;
}
dp = dp2;
}
cout << res << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif
using namespace std;
using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);
template<class T> inline T sqr(T x) {return x*x;}
double f(int x, double p) {
return x / (2.0 * p);
}
int main() {
int x,p;
cin >> x >> p;
if (p == 100) {
cout << (x + 1) / 2 << endl;
}
if (x % 2 == 1) {
//cout << (1-1.0*p/100) + 1 + (x - 1) / (2.0 * p / 100) << endl;
//cout << (x - 1) / (2.0 * p / 100) << endl;
//printf("%.08f\n", (1-1.0*p/100) + 1 + (x - 1) / (2.0 * p / 100));
printf("%.08f\n", 1+1.0*p/100*(f(x-1,1.0*p/100))+(1-1.0*p/100)*(f(x+1,1.0*p/100)));
} else {
//cout << x / (2.0 * p / 100) << endl;
printf("%.08f\n", f(x, 1.0*p/100));
}
return 0;
} |
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | x = int(input())
p = int(input())
p *= 0.01
print((x+1)//2/p)
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x1f1f1f1f;
const long long INFLL = 0x1f1f1f1f1f1f1f1fLL;
template <class A, class B>
inline ostream& operator<<(ostream& st, const pair<A, B>& P) {
return st << "(" << P.first << "," << P.second << ")";
};
template <class A, class B>
inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) {
return pair<A, B>(P.first + Q.first, P.second + Q.second);
};
template <class A, class B>
inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) {
return pair<A, B>(P.first - Q.first, P.second - Q.second);
};
long long bitcount(long long bits) {
bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);
bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);
bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);
bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);
bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff);
return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff);
}
int main() {
int x, p;
cin >> x >> p;
cout << (x + 1) / 2 << endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
int main() {
long long x, p;
std::cin >> x >> p;
if (x % 2 == 0)
std::cout << x / 2 << ".00000000" << std::endl;
else
std::cout << x / 2 + 1 << std::endl;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll X, P;
const int MAX_TURN = 100;
map<tuple<int, int, int>, double> dp;
double memo(int turn, int pos_ao, int pos_cho) {
if (pos_ao == pos_cho) {
return turn;
}
if (turn >= MAX_TURN) {
return INF;
}
double pro = (double)P / 100;
if (dp.count(make_tuple(turn, pos_ao, pos_cho)) > 0) {
return dp[make_tuple(turn, pos_ao, pos_cho)];
}
double result = INF;
result = min(result, memo(turn + 1, pos_ao - 1, pos_cho - 1) * pro +
memo(turn + 1, pos_ao - 1, pos_cho + 1) * (1 - pro));
result = min(result, memo(turn + 1, pos_ao, pos_cho - 1) * pro +
memo(turn + 1, pos_ao, pos_cho + 1) * (1 - pro));
result = min(result, memo(turn + 1, pos_ao + 1, pos_cho - 1) * pro +
memo(turn + 1, pos_ao + 1, pos_cho + 1) * (1 - pro));
dp[make_tuple(turn, pos_ao, pos_cho)] = result;
return result;
}
int main() {
cin >> X >> P;
if (X > 10) return 0;
double result = memo(0, 0, X);
printf("%.20lf\n", result);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
long long x;
cin >> x;
double y = x;
double p;
cin >> p;
if (p == 100) {
x++;
cout << x / 2 << endl;
return 0;
}
p /= 100.0;
if (x % 2 == 0) {
cout << y / 2.0 / p << "\n";
} else {
y++;
cout << y / 2.0 / p + 1 << "\n";
}
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main(void) {
int a[100000];
int c[100000];
int s;
int n;
int x;
int y;
int z;
scanf("%d", &x);
scanf("%d", &n);
printf("%d", (x + 1) / 2);
return 0;
}
|
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing! | Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.
Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:
* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.
* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.
When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.
Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.
Constraints
* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.
Input
The input is given from Standard Input in the following format:
x
p
Output
Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.
Examples
Input
3
100
Output
2.0000000
Input
6
40
Output
7.5000000
Input
101
80
Output
63.7500000 | {
"input": [
"6\n40",
"101\n80",
"3\n100"
],
"output": [
"7.5000000",
"63.7500000",
"2.0000000"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-8;
const int inf = 1e8;
int main() {
int x;
double p;
cin >> x >> p;
if (p == 100) {
cout << (x + 1) / 2 << endl;
return 0;
}
vector<double> dp(2000);
dp[x - 1] = 1;
double out = 0;
for (int i = 0; i < 2000; i++) {
vector<double> ndp(2000);
for (int j = i; j < 2000; j++) {
if (j)
ndp[j - 1] += dp[j] * p / 100;
else
out += dp[0] * p / 100;
if (j != 1999) ndp[j + 1] += dp[j] * (100 - p) / 100;
}
dp = ndp;
for (int j = 0; j < i + 1; j++) out += dp[j] * (i + 1);
}
cout << fixed << setprecision(9) << out << endl;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.