Submission #1694883


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

long double mypow(long double a,ll n){
  long double res=1.0; 
  while(n>0){
    if(n&1)res=res*a;
    a=a*a;
    n>>=1;
  }
  return res;
}

long double p;
ll n;

int main(){
	cin>>p>>n;
  if(p==0){
    printf("0\n");
    return 0;
  }
  long double q=(1-2*p);
  long double res=(p*(1-mypow(q,n)))/(1-q);
  printf("%.15Lf\n", res);
	return 0;
}

Submission Info

Submission Time
Task A - eject
User yamad
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1033 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 33
Set Name Test Cases
All 00-sample-00, 00-sample-01, 10-random_small-00, 10-random_small-01, 10-random_small-02, 10-random_small-03, 10-random_small-04, 10-random_small-05, 10-random_small-06, 10-random_small-07, 10-random_small-08, 10-random_small-09, 20-random_large-00, 20-random_large-01, 20-random_large-02, 20-random_large-03, 20-random_large-04, 20-random_large-05, 20-random_large-06, 20-random_large-07, 20-random_large-08, 20-random_large-09, 30-p_zero-00, 30-p_zero-01, 30-p_zero-02, 30-p_zero-03, 30-p_zero-04, 40-p_one-00, 40-p_one-01, 40-p_one-02, 40-p_one-03, 40-p_one-04, 90-handmade-00
Case Name Status Exec Time Memory
00-sample-00 AC 1 ms 256 KB
00-sample-01 AC 1 ms 256 KB
10-random_small-00 AC 1 ms 256 KB
10-random_small-01 AC 1 ms 256 KB
10-random_small-02 AC 1 ms 256 KB
10-random_small-03 AC 1 ms 256 KB
10-random_small-04 AC 1 ms 256 KB
10-random_small-05 AC 1 ms 256 KB
10-random_small-06 AC 1 ms 256 KB
10-random_small-07 AC 1 ms 256 KB
10-random_small-08 AC 1 ms 256 KB
10-random_small-09 AC 1 ms 256 KB
20-random_large-00 AC 1 ms 256 KB
20-random_large-01 AC 1 ms 256 KB
20-random_large-02 AC 1 ms 256 KB
20-random_large-03 AC 1 ms 256 KB
20-random_large-04 AC 1 ms 256 KB
20-random_large-05 AC 1 ms 256 KB
20-random_large-06 AC 1 ms 256 KB
20-random_large-07 AC 1 ms 256 KB
20-random_large-08 AC 1 ms 256 KB
20-random_large-09 AC 1 ms 256 KB
30-p_zero-00 AC 1 ms 256 KB
30-p_zero-01 AC 1 ms 256 KB
30-p_zero-02 AC 1 ms 256 KB
30-p_zero-03 AC 1 ms 256 KB
30-p_zero-04 AC 1 ms 256 KB
40-p_one-00 AC 1 ms 256 KB
40-p_one-01 AC 1 ms 256 KB
40-p_one-02 AC 1 ms 256 KB
40-p_one-03 AC 1 ms 256 KB
40-p_one-04 AC 1 ms 256 KB
90-handmade-00 AC 1 ms 256 KB