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 |
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
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;
}