Submission #1710933


Source Code Expand

#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef vector<long double> vec;
typedef vector<vec> mat;

mat mul(mat &A, mat &B) {
  mat C(A.size(), vector<long double>(B[0].size()));
  REP(i, 0, A.size())
    REP(j, 0, B[0].size())
      REP(k, 0, B.size())
        C[i][j] += A[i][k] * B[k][j];
  return C;
}

mat pow(mat A, ll n) {
  mat B(A.size(), vec(A.size()));
  REP(i, 0, A.size()) B[i][i] = 1;
  while(n > 0) {
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

int main(void) {
  long double P;
  ll N;
  cin >> P >> N;

  mat A(2, vec(2));
  A[0][0] = 1 - P; A[0][1] = P;
  A[1][0] = P; A[1][1] = 1 - P;

  printf("%.15Lf\n", pow(A, N)[0][1]);
}

Submission Info

Submission Time
Task A - eject
User kshinya
Language C++14 (GCC 5.4.1)
Score 0
Code Size 808 Byte
Status WA
Exec Time 2 ms
Memory 384 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 24
WA × 9
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 2 ms 384 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 WA 1 ms 256 KB
20-random_large-01 WA 1 ms 256 KB
20-random_large-02 WA 1 ms 256 KB
20-random_large-03 WA 1 ms 256 KB
20-random_large-04 WA 1 ms 256 KB
20-random_large-05 AC 1 ms 256 KB
20-random_large-06 WA 1 ms 256 KB
20-random_large-07 WA 1 ms 256 KB
20-random_large-08 WA 1 ms 256 KB
20-random_large-09 WA 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