首页 > 其他 > 详细

csuoj-1003-UC Browser

时间:2017-04-10 20:41:02      阅读:427      评论:0      收藏:0      [点我收藏+]

题目:

Description

Brother Xi has recently bought a smart mobile phone. Now he surfs Internet by his mobile phone almost every day. The browser that he uses is UC Browser, which is one of the most popular mobile browsers. To better grasp the users, UC Corporation have also brought out the level system of user account. The higher the level of your account, the more privileges you can enjoy. The level of your account is calculated by your experiences. The correspondence of level and experience is as follows:

LevelExperiencesLevelExperiencesLevelExperiences
0 0-49 3 250-349 6 550-649
1 50-149 4 350-449 7 650-749
2 150-249 5 450-549 8 >=750

You can get 10 experiences after using UC Browser one day in a row, 20 experiences for two days in a row, 30 experiences for three days in a row, 40 experiences for four days in a row, 50 experiences for five days in a row. If you use UC Browser six days in a row, the experiences you can get will be equal 10, like your using UC Browser one day in a row. It‘s come back to the starting of your using UC Browser. It‘s a circle.

Now you have known the Xi‘s record of using UC Browser, I‘ll hope you calculate the level of Xi‘s account.

Input

The first line of the input contains a single integer T (0<T<120) which is the number of test cases, followed by 2*T lines. For each test case, the first line is the number of days n (0<n<=100), the second line is a series of 0 and 1. 0 stands for not using UC browser on that day and 1 stands for using UC browser on that day.

Output

For each test case, output the corresponding level of Xi’s account in one line.

Sample Input

2
6
110101
12
111111110101

Sample Output

1
2


代码:
 1 #include<iostream>
 2 using namespace std;
 3 int main(){
 4     int t;
 5     cin >>t;
 6     char ch[101];
 7     while(t--){
 8         int n;
 9         cin >>n;
10         cin >>ch;
11         int total = 0;
12         int cnt = 0;
13         for(int i = 0;i < n;i++){
14             if(ch[i] == 1){
15                 switch(cnt){
16                     case 0: total += 10;cnt++;break;
17                     case 1: total += 20;cnt++;break;
18                     case 2: total += 30;cnt++;break;
19                     case 3: total += 40;cnt++;break;
20                     case 4: total += 50;cnt = 0;break;
21                 }
22             }//if
23             else{
24                 cnt = 0;
25             }//else
26         }//for
27         int level = 0;
28         if(total >= 0 && total <= 49)
29             cout << 0 << endl;
30         else if(total >= 50 && total <= 149)
31             cout << 1 << endl;
32         else if(total >= 150 && total <= 249)
33             cout << 2 << endl;
34         else if(total >= 250 && total <= 349)
35             cout << 3 << endl;
36         else if(total >= 350 && total <= 449)
37             cout << 4 << endl;
38         else if(total >= 450 && total <= 549)
39             cout << 5 << endl;
40         else if(total >= 550 && total <= 649)
41             cout << 6 << endl;
42         else if(total >= 650 && total <= 749)
43             cout << 7 << endl;
44         else cout << 8 << endl;
45     }//while
46     return 0;
47 }

 


csuoj-1003-UC Browser

原文:http://www.cnblogs.com/tracy520/p/6690516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!