提出 #5476041


ソースコード 拡げる

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/






int N, K;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;

	double ans = 0;
	rep(x, 1, N + 1) {
		int y = x;
		double q = 1.0 / N;
		while (y < K) {
			y *= 2;
			q /= 2;
		}
		ans += q;
	}
	printf("%.10f\n", ans);
}

提出情報

提出日時
問題 C - Dice and Coin
ユーザ hamayanhamayan
言語 C++14 (GCC 5.4.1)
得点 300
コード長 1571 Byte
結果 AC
実行時間 1 ms
メモリ 256 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 7
セット名 テストケース
Sample 01.txt, 02.txt
All 01.txt, 02.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt
ケース名 結果 実行時間 メモリ
01.txt AC 1 ms 256 KiB
02.txt AC 1 ms 256 KiB
11.txt AC 1 ms 256 KiB
12.txt AC 1 ms 256 KiB
13.txt AC 1 ms 256 KiB
14.txt AC 1 ms 256 KiB
15.txt AC 1 ms 256 KiB