結果

問題 No.667 Mice's Luck(ネズミ達の運)
ユーザー hkarintohkarinto
提出日時 2018-06-10 17:50:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 753 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 87,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 02:42:01
合計ジャッジ時間 3,034 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:12:6: 警告: ‘s’ is used uninitialized [-Wuninitialized]
   12 | cin>>s;
      |      ^
main.cpp:11:10: 備考: ‘s’ はここで定義されています
   11 |    char *s;
      |          ^

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
   int n=10000;

   char *s;
cin>>s;

int N=0;
for(int i=0;i<n;i++){
    if(s[i]=='\0'){
    break;
    }
    N+=1;
}
n=N;

int *x;
x= new int[n];


for (int i=0;i<n;i++){
    x[i]=0;
}

if(s[n-1]=='o'){
    x[n-1]=1;
}

for (int i=n-2;i>=0;i--){
    x[i]=x[i+1];
   if(s[i]=='o'){
       x[i]+=1;
   }
}

for(int i=0;i<n;i++){
   
    int count=100;
    int surv =0;
    for(int j=i;j<n;j++){

        if(s[j]=='o'){
           
            surv +=1;
        }
    }
    count=n-i;
    if(count==0){
    return 0;
    }
    float ans =100.0*surv/count;
    cout<<fixed << setprecision(10)<<ans<<"\n";
}
/**/
    return 0;
}
0