ACM:H: UC Browser

ACM:H: 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:

Level Experiences Level Experiences Level Experiences
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
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define LL long long
#define MAX(a,b)((a)>(b)?a:b)
#define MIN(a,b)((a)<(b)?a:b)
#define INF 0x7ffffff
#define N 105
#define M 405
using namespace std;
char a[N];
int main()
{
    int T;
    int n,i;
    cin>>T;
    while(T--)
    {
        int num=0,count=0;
        int level=0;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(i=0;i<n;i++)
        {
            if(a[i]=='1')
            {
                switch(count){
                case 0:num +=10;count++;break;
                case 1:num +=20;count++;break;
                case 2:num +=30;count++;break;
                case 3:num +=40;count++;break;
                case 4:num +=50;count=0;break;
                }
            }
            else
                count=0;
        }
        if(num>=750)
            level=8;
        else if(num>=650)
            level=7;
        else if(num>=550)
            level=6;
        else if(num>=450)
            level=5;
        else if(num>=350)
            level=4;
        else if(num>=250)
            level=3;
        else if(num>=150)
            level=2;
        else if(num>=50)
            level=1;
        else
            level=0;
        //cout<<count<<endl;
        cout<<level<<endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值