nyoj125盗梦空间

来源:互联网 发布:java 集合的应用 编辑:程序博客网 时间:2024/04/29 22:04
#include <stdio.h>
#include <string.h>
int main()
{
    int n, count, i, num, m, a;
    double time;
    scanf("%d", &n);
    char ch[10];
    while(n--)
    {
        scanf("%d", &num);
        time = 0;
        count = 0;
        while(num--)
        {
            getchar();
            scanf("%s", ch);
            if(strcmp(ch, "IN") == 0)
            {
                count++;
            }
            else if(strcmp(ch, "STAY") == 0)
            {
                a = 1;
                scanf("%d", &m);//printf("%d", count);
                for(i = 0; i < count; i++)
                {
                    a *= 20;
                }//printf("%d\t%d\t", a, m/a);
                time = time + m*1.0 / a;//printf("%f", time);
            }
            else if(strcmp(ch, "OUT") == 0)
            {
                count--;
            }
        }
        printf("%.0f\n", time * 60);
    }
    return 0;
}
0 0
原创粉丝点击