Algorithm


Problem Name: beecrowd | 2147

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2147

Galopeira

 

By Ricardo Martins, IFSULDEMINAS BR Brazil

Timelimit: 1

One day, the brothers Little Chitão and Xor Or Oh, great typists, made ​​a challenge to see who was the best in typing. For this, they obtained a computer that does not process keystrokes, ie, if it is to enter the same letter twice in a row, to press the button twice, as, press for longer, no use. They also measured the time down a key, which was exactly 1/100 second. The challenge would be who typed the word "Galopeira" consisting of letters and more, but both were very good, and arrived at a point that it was not possible to count how many letters had been typed. Then asked his help to write a program that checks the typed word and see how much time was spent typing.

Write a program that, given a typed word, tell how much time was spent to be entered.

 

Input

 

An integer C will be informed, which is the amount of test cases. Each case has a word of at least 9 and at most 10,000 letters.

 

Output

 

For each test case, print a T number, which is the time spent, in seconds, to enter the word of their test case, with precision of two decimal digits.

 

 

 

Input Sample Output Sample

3

galopeira

galopeeeeeeeeeeeeeeeeeira

galopeeira

0.09

0.25

0.10

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(void)

{
    int i, j, n;
    char str[10000];
    double x;

    scanf("%i", &n);

    for (i = 0; i  <  n; ++i)
    {
        scanf("%s", str);
        j=0;
        while (str[j] != 0)
            ++j;

        x = j/100.0;

        printf("%.2lf\n", x);
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 galopeira galopeeeeeeeeeeeeeeeeeira galopeeira

Output

x
+
cmd
0.09 0.25 0.10

#2 Code Example with C++ Programming

Code - C++ Programming


#include<stdio.h>
#include<string.h>
int main()
{
    int test;
    double len;
    char ch[10000];
    scanf("%d",&test);
    while(test--){
        scanf("%s",&ch);
        len = strlen(ch);
        printf("%.2lf\n",len/100);
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 galopeira galopeeeeeeeeeeeeeeeeeira galopeeira

Output

x
+
cmd
0.09 0.25 0.10

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

const arroz = lines.shift();
let cont = 0;

for(let i = 0; i  <  arroz; i++){
    let word = lines.shift().trim();
    for(let j = 0; j  <  word.length; j++){
        cont += 0.01;
    }
    console.log(cont.toFixed(2));
    cont = 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 galopeira galopeeeeeeeeeeeeeeeeeira galopeeira

Output

x
+
cmd
0.09 0.25 0.10
Advertisements

Demonstration


Previous
#2146 Beecrowd Online Judge Solution 2146 Password Solution in C, C++, Java, Js and Python
Next
#2152 Beecrowd Online Judge Solution 2152 Pepe, I Already Took the Candle! Solution in C, C++, Java, Js and Python