csuoj-1003-UC Browser

Posted znt

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csuoj-1003-UC Browser相关的知识,希望对你有一定的参考价值。

题目:

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的主要内容,如果未能解决你的问题,请参考以下文章

Android 逆向使用 DB Browser 查看并修改 SQLite 数据库 ( 从 Android 应用数据目录中拷贝数据库文件 | 使用 DB Browser 工具查看数据块文件 )(代码片段

如何在CEF JS与browser进程间异步通信

更新到 jQuery 1.9.1 后 browser.msie 错误

gulp-nodemon + browser-sync:服务器端代码更改后应用程序不会重新加载

PPAPI与Browser间使用AsyncIPC通信

判断浏览器browser类型