結果

問題 No.667 Mice's Luck(ネズミ達の運)
ユーザー @abcde@abcde
提出日時 2019-02-27 00:21:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 145,196 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 09:04:42
合計ジャッジ時間 3,271 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 26 ms
4,380 KB
testcase_06 AC 123 ms
4,376 KB
testcase_07 AC 247 ms
4,376 KB
testcase_08 AC 190 ms
4,376 KB
testcase_09 AC 180 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    
    // 1. 入力情報取得.
    string S;
    cin >> S;
    
    // 2. 助かる確率は?
    int o = 0, x = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'o') o++;
        else            x++;
    }
    
    // 3. 出力 ~ 終了.
    for(int i = 0; i < S.size(); i++){
        char c = S[i];

        // 3-1. ネズミの助かる確率を計算.
        double ans = 100 * o / (o + x + 0.0);
        cout << fixed;
        cout << setprecision(13) << ans << endl;

        // 3-2. 安全な箱 or ネズミ捕りが仕掛けられた箱 の個数を更新.
        if(c == 'o') o--;
        if(c == 'x') x--;
    }
    return 0;
    
}
0