UC browser

来源:互联网 发布:上海网络企业排名 编辑:程序博客网 时间:2024/04/27 19:12


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

2611010112111111110101

Sample Output

12

HINT

下面是代码

#include<iostream>
int main(void)
{
 int a[9][2]={{0,49},{1,149},{2,249},{3,349},{4,449},{5,549},{6,649},{7,749},{8,750}};
 int level;
 int count;
 int len;
 int days,length=0,i;
 char chs[101]={0};
 int elememt_case;
 scanf("%d",&elememt_case);
 while (elememt_case--)
 {
  level = 0;
  count = 0;
  len = 1;
  scanf("%d",&days);
  scanf("%s",chs);
  length = days;
  for (i=0;i<length;i++)
  {
   if ((len % 6)== 0)
   {
    len = 1;
   }
   if (chs[i]=='1')
   {
    count += 10*(len%6);
    len++;
    continue;
   }
   len = 1;
  }
  for (i=0;i < 9;i++)
  {
   if (i == 8)
   {
    level = 8;
    break;
   }
   if (count <= a[i][1])
   {
    level = a[i][0];
    break;
   }
   //level++;
  }
  printf("%d\n",level);
 }
 return 0;
}#include<iostream>
int main(void)
{
int a[9][2]={{0,49},{1,149},{2,249},{3,349},{4,449},{5,549},{6,649},{7,749},{8,750}};
int level;
int count;
int len;
int days,length=0,i;
char chs[101]={0};
int elememt_case;
scanf("%d",&elememt_case);
while (elememt_case--)
{
level = 0;
count = 0;
len = 1;
scanf("%d",&days);
scanf("%s",chs);
length = days;
for (i=0;i<length;i++)
{
if ((len % 6)== 0)
{
len = 1;
}
if (chs[i]=='1')
{
count += 10*(len%6);
len++;
continue;
}
len = 1;
}
for (i=0;i < 9;i++)
{
if (i == 8)
{
level = 8;
break;
}
if (count <= a[i][1])
{
level = a[i][0];
break;
}
//level++;
}
printf("%d\n",level);
}
return 0;
}

0 0