CSU 1003 UC Browser

来源:互联网 发布:java 并发控制 编辑:程序博客网 时间:2024/09/21 08:50

1003: UC Browser

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1386  Solved: 465
[Submit][Status][Web Board]

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

Source

中南大学第五届大学生程序设计竞赛-热身赛


模拟题,注意浮点数转换

#include<iostream>using namespace std;char a[105];int getlevel(int sum){    int level = 8;    if (sum<750)    {        if (sum >= 0 && sum <= 49)            level = 0;        if (sum >= 50 && sum <= 149)            level = 1;        if (sum >= 150 && sum <= 249)            level = 2;        if (sum >= 250 && sum <= 349)            level = 3;        if (sum >= 350 && sum <= 449)            level = 4;        if (sum >= 450 && sum <=549)            level = 5;        if (sum >= 550 && sum <= 649)            level = 6;        if (sum >= 650 && sum <= 749)            level = 7;    }    return level;} int getscore(int i){    if (i < 5)        return (i*(i+1))/2*10;    else        return 150 * (i / 5) + getscore(i%5);}int main(){    int T;    cin >> T;    while (T--)    {        int num, k = 1;        int sum = 0;        cin >> num;        cin >> a;        for (int i = 0; i < num; i++)            if (a[i] == '1')            {                if (a[i + 1] == a[i])                {                    k++;                    continue;                }                sum += getscore(k);                    k = 1;            }        cout << getlevel(sum)<<endl;    }} /**************************************************************    Problem: 1003    User: 0905130123    Language: C++    Result: Accepted    Time:0 ms    Memory:1484 kb****************************************************************/


0 0
原创粉丝点击