Dream space, dream space

Source: Internet
Author: User
Tags first string

Dream space, dream space
Source of the dream space time limit: 3000 MS | memory limit: 65535 KB difficulty: 2

Description

In this movie, ke and others can enter the dream, and the time in the dream will be much faster than the real time, assume that in reality, 3 minutes is 1 hour in the dream.

However, they can use powerful anesthesia to enter the second-level dream from the first-level dream, or even the third-level dream. Each layer of dream will produce the same time acceleration effect. So now, how long have you been in the real world after giving you the experience of data in various layers of dreams?

For example, after waiting for an hour in the first-level dream, and one day in the second-level dream, he immediately returned to the reality after returning to the first-level dream.

In the real world, it actually takes 396 seconds (6.6 minutes)

Input
In the first line, enter an integer T (0 <= T <= 100), indicating the number of test data groups.
The first row of each group of test data is a number M (3 <= M <= 100)
The next M-line starts with a string. If the string is "IN", data is redirected to a deeper dream, if it is a string "OUT", it indicates that the data goes back to the previous layer from deep dream. If the first string is "STAY", it indicates that data has stayed in this layer for a while, this row will then be an integer "S", indicating that the layer has stayed for S minutes (1 <= S <= 10000000 ). In the real world, data is guaranteed to take an integer second.
Output
For each group of test data, the output time of the real world (in seconds ).
Sample Input
16INSTAY 60INSTAY 1440OUTOUT
Sample output
396

Direct code:

# Include <stdio. h> void deal () {int time = 0, w = 1; // time is the target time, w is the time scale int m, temp; char s [10]; scanf ("% d", & m); while (m --) {scanf ("% s", s); // printf ("s = % s \ n ", s); if (s [0] = 'I') // if it is IN w * = 20; else if (s [0] = 'O ') // if it is OUT w/= 20; else {// if not, it must be STAYscanf ("% d", & temp); temp * = 60; // converts the time to seconds, in the unit of time + = temp/w; // converts the time to the actual time and accumulates} printf ("% d \ n", time );} int main () {int n; scanf ("% d", & n); while (n --) {deal ();} return 0 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.