zoukankan      html  css  js  c++  java
  • 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 }
    
    
  • 相关阅读:
    摩拜单车--获地球卫士奖
    项目经理--读书静心的日子
    20165219 Exp1 PC平台逆向破解
    2018-2019-2 20165219《网络对抗技术》Exp0 Kali安装 Week1
    2018-2019-1 20165219《信息安全系统设计基础》实验五
    ### 2018-2019-1 20165219《信息安全系统设计基础》实验四
    实现mypwd
    mybash的实现
    2018-2019-1 20165219 实验三 实时系统
    2018-2019-1 20165219 《信息安全系统设计基础》第七周学习总结
  • 原文地址:https://www.cnblogs.com/tracy520/p/6690516.html
Copyright © 2011-2022 走看看