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.
For each test case, output the corresponding level of Xi’s account in one line.
2
6
110101
12
111111110101
1
2
#include <iostream>
#include <string>
using namespace std;
int c,sum;
void run(int a)
{
if (a==0) c=0;
else
{
c++;
c=c%5;
}
if ((c==0)&&(a==1)) sum=sum+50;
else if (a==1) sum=sum+c*10;
}
int judge(int a)
{
if (a<50) return 0;
else if (a<150) return 1;
else if (a<250) return 2;
else if (a<350) return 3;
else if (a<450) return 4;
else if (a<550) return 5;
else if (a<650) return 6;
else if (a<750) return 7;
else return 8;
}
int main()
{
string s;
int n,i,j,a,l;
cin>>n;
for (i=0;i<n;i++)
{
sum=0;
c=0;
cin>>l;
cin>>s;
for (j=0;j<l;j++)
{
a=s[j]-'0';
run(a);
}
cout<<judge(sum)<<endl;
}
return 0;
}