NYOJ 125 盗梦空间

 1 #include<stdio.h> 
 2 #include<stdlib.h>
 3 #include<string.h>
 4 int main()
 5 {
 6     int n,m,i,t ,s,w;;
 7     char str[10];
 8     scanf("%d",&n);
 9     while(n--)
10     {
11         scanf("%d",&m);
12         s = 0; w = 1; i= 0;
13         while(m--)
14         {
15             scanf("%s",&str);
16             if(strcmp(str , "IN")==0)
17             w *= 20;
18             else if(strcmp(str , "STAY")==0)
19                 {
20                    scanf("%d",&t);
21                    s += (t*60)/w;
22                 }
23             else
24                 {i--;w /=20;}
25         }
26         printf("%d\n",s);
27     }
28     system("pause");
29     return 0;
30 }
 1 #include<iostream>
 2 #include<string>
 3 using namespace std;
 4 int main()
 5 {
 6     int N;
 7     cin>>N;
 8     while(N--)
 9     {
10           string str;
11           int m, second=0, div=1;
12           cin>>m;
13           while(m--)
14           {
15                 cin>>str;
16                 if(str == "IN")
17                   div *= 20;
18                 else if(str == "STAY")
19                 {
20                   int stay;
21                   cin>>stay;
22                   second += (stay * 60) / div;
23                 }
24                 else
25                   div /= 20;
26           }
27          cout<<second<<endl;
28     }
29     return 0;
30 }

posted on 2012-08-09 20:54  mycapple  阅读(294)  评论(0编辑  收藏  举报

导航