-->
当前位置:首页 > 题库

PROGRAMMING:Win gold step by step

Luz5年前 (2021-05-10)题库434
Ivy's company wants to launch a mobile app "step by step gold", which can count the number of steps users walk every day and give corresponding "gold" rewards. After the user's "gold coins" reach a certain amount, they can exchange certain sporting goods on the company's website.
According to the number of steps x, the rules of rewarding gold coins are as follows:
1. You can get 0.3 gold coins for the first 1000 steps every day (if you don't reach 1000 steps, you can get zero), and you can get 0.1 gold coins for every 2000 steps. In order to guide users to exercise properly, the number of gold coins they receive per day should not exceed 3.
2. Only by clicking "sign in" in the app can users get the gold coins corresponding to the steps of the day.
3. In order to make users insist on using the app every day, after the user signs in for three consecutive days, starting from the fourth day, the number of gold coins received by the user when "signing in" every day can be multiplied by 2 on the basis of the original gold coin calculation method (of course, the premise is that the user also clicks "sign in" on the fourth day, and the gold coins received can not exceed 6 at most). But after that, as long as you stop clicking "sign in" one day, you have to sign in again for three consecutive days, and you can continue to get double gold discount on the fourth day.
Ivy's task is to count the total number of gold coins owned by users after n days according to the number of steps they take every day and the check-in situation. Please help Ivy design this program.
###Input format:
There are n + 1 lines in the input. The first line contains a positive integer n, indicating that the total number of gold coins of the user after n days needs to be counted. Next, there are n (1 < = n < = 100) rows, two positive integers in each row, Xi (1 < = Xi < = 100000) and fi (1 or 0), which respectively represent the steps taken by the user on day I and whether the user checked in on that day. If FI is 0, it means that the user did not click "sign in" on the same day; if FI is 1, it means that the user clicks "sign in" on the same day.
###Output format:
The output data is only one line, which represents the total number of gold coins owned by the user after n days, with one decimal place reserved.
###Input example:
```in
six
600 1
2300 1
5000 1
56000 1
80000 0
57000 1
```
###Output example:
The corresponding output is given here. For example:
```out
nine point eight
```
[input and output example description]
Day 1: the user takes 600 steps, less than 1000 steps, and gets 0 gold coin after signing in.
The next day: after 2300 steps, the user can get 0.3 gold coins in the first 1000 steps; 2300-1000 = 1300, less than 2000 steps. So you can get 0.3 gold coin after you sign in.
Day 3: after 5000 steps, the user can get 0.3 + 0.1 * 2 = 0.5.
The fourth day: the user walked 56000 steps. After checking in, the gold coin he deserved was 0.3 + 0.1 * 27 = 3. Because it was the fourth day in a row, I actually got 3 * 2 = 6 gold coins.
Day 5: the user walked 80000 steps, but did not sign in, so the gold coin was 0.
Day 6: after the user has taken 57000 steps to sign in, his due gold coin is: 0.3 + 0.1 * 28 = 3.1. As the daily maximum gold can not be more than 3, so actually get 3 gold coins.
According to the above daily gold coins, the total number of "gold coins" that the user can get after 6 days is 9.8.







answer:If there is no answer, please comment