"Luogu OJ" "C + +" level 1-2

Source: Internet
Author: User

Level 1-2, 3 problem sequence and branching

Task Description: The intelligence of the computer begins to be reflected, because the computer can choose according to different conditions.

To complete this task, please AC down the following topics (i.e. through this topic):

1. Small Yujia of electricity

2. Unhappy Jinjin

3. Jinjin's Savings plan

Achievement time: 2015-07-14-20:26

1. Small Yujia's electricity P1422

In summer, the electricity consumption of households has increased, and the corresponding electricity tariffs have been paid more. Little Yujia received a bill of electricity today. Jade See above write: According to Min-Price electricity [2006]27 number, the monthly electricity consumption in 150-kilowatt hours and the following part of 0.4463 yuan per kilowatt-hour, the monthly electricity consumption in the 151~ At 400-kilowatt, the part is executed at $0.4663 per kilowatt-hour, and the monthly electricity consumption at 401-kilowatt hours and above is executed at $0.5663 per kilowatt-hour. Xiao Yu wants to verify for himself, whether the number of electricity bills should be paid on the bill is correct. Please write a program, known electricity total, according to electricity price rules, calculate how much electricity should be paid.

Input format:
Enter an integer that represents the total power consumption (in kilowatt-hour units), not exceeding 10000.
Output format:
Outputs a number, reserved to 1 digits after the decimal point (in meta-units, reserved to 1 digits after the decimal point).

That's the pit. I've been seeing the sixth chapter of C + + primer ... (HHHH)

And then the egg ... I still bing to how to keep decimals ...

As a CIN cout party is how not easy ...

1#include <iostream>2#include <iomanip>3 using namespacestd;4 intMain ()5 {6     intW;7Cin>>W;8     if(w< Max) 9Cout<<setiosflags (iOS::fixed) <<setprecision (1) <<w*0.4463<<Endl;Ten     if((w>= Max) && (w<= -)) OneCout<<setiosflags (iOS::fixed) <<setprecision (1) << (w Max)*0.4663+66.945<<Endl; A     if(w> -)  -Cout<<setiosflags (iOS::fixed) <<setprecision (1) << (w -)*0.5663+183.52<<Endl; -   return 0; the}

Think of As long as Writeln (W:0:1) is finished ... Today the pit is like this ...

But then again ... It's so cout, uh.

Water to the incomparable, there is nothing to say.

Note #include<iomanip>

2. Unhappy Jinjin P1085

Jinjin on the middle school. Mother think Jinjin should study harder, so jinjin in addition to school, but also to participate in the mother for her to enroll in the various subjects review class. In addition, the weekly mother will send her to learn recitation, dance and piano. But Jinjin would be unhappy if he had been in school for more than eight hours a day, and the longer he would be unhappy. Suppose Jinjin not be unhappy with anything else, and her unhappy will not last until the next day. Please check the schedule of Jinjin next week to see if she will be unhappy next week, and if so, which day is the most unhappy.

Input format:
The input file unhappy.in includes seven rows of data, representing the schedule from Monday to Sunday, respectively. Each line consists of two non-negative integers less than 10, separated by spaces, indicating Jinjin's time in school and her mother's schedule for the class.
Output format:
The output file Unhappy.out includes one row, which contains only a single number. If not unhappy then output 0, if the output is the most unhappy is the number of weeks (with 1, 2, 3, 4, 5, 6, 7 respectively represents Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday). If there are two or two days above the level of unhappy, then the output time is the most forward day.

I'm going to be happy to cry (not Qiku)

It is estimated that the original boring time at least brush 5 times ... A variety of boring algorithms

1#include <iostream>2 using namespacestd;3 intMain ()4 {5     intSchool, After_school;6     inthrs,day,hours;7day=0;8hours=8;9      for(intI=0; i<=6;++i)Ten     { OneCin>>school>>After_school; Ahrs=school+After_school; -        if(hrs>hours) -          { theday=i+1; -hours=hrs; -          } -     } +cout<<day<<Endl; -   return 0;  +}

Unfortunately not to see my Pascal all kinds of Wonderful edition ... rqnoj Vijos TYVJ there must be many editions, hhhhh

3. Jinjin's Savings Plan P1089

Jinjin's pocket money has always been his own management. At the beginning of each month, the mother gave Jinjin 300 yuan, Jinjin will budget this month's expenses, and can always achieve the actual cost and the same budget.

In order to let Jinjin learn how to save, mother proposed, Jinjin can at any time the whole hundred of money exists her there, to the end of the year she will add 20% to Jinjin. So Jinjin a savings plan: the beginning of each month, after getting her mother's allowance, if she expects to have more than 100 yuan or just 100 yuan at the end of this month, she will put the whole hundred of money in the mother, the rest of the money left in their hands.

For example, in early November Jinjin hand still had 83 yuan, mother gave Jinjin 300 yuan. Jinjin is expected to spend 180 yuan in November, then she will save 200 yuan for her mother, leaving 183 yuan herself. By the end of November, Jinjin would have left 3 yuan in his hand.

Jinjin found that the main risk of the savings plan was that there was no mother's money to be taken out until the end of the year. It is possible that at the beginning of the month, Jinjin's money plus this month's mother's money, not enough for this month's original budget. If this happens, Jinjin will have to pinch and compress the budget this month.

Now, judging from the January 2004 to December monthly Jinjin budget, you will see if this is going to happen. If not, to the end of 2004, the mother will jinjin the usual amount of money plus 20% back to Jinjin, Jinjin hands will have how much money.

Input format:
The input file save.in includes 12 rows of data, each containing a non-negative integer less than 350, representing the budget for the Jinjin from January to December, respectively.
Output format:
The output file Save.out includes one row, which contains only an integer. If a liken is not sufficient in the implementation of the savings plan, the output-x,x indicates the first month of the situation, otherwise the output will be jinjin in the hands of the end of 2004.

Think about how harmonious noip ... In particular, the 2004 sample, Hhhhh

It was also a happy Cry (HHH)

1#include <iostream>2 using namespacestd;3 intMain ()4 {5     intmoney=0;6     intjj=0;7     intMom=0;8    for(intI=0; i<= One;++i)9     {TenCin>>Money ; Onejj+= ( --Money ); A         if(jj<0) -           { -cout<<"-"<<i+1<<Endl; the               return 0; - exit; -           }           -         if(jj>= -) +           { -            intTmp= ((jj/ -)* -); +mom+=tmp; Ajj-=tmp; at           } -     } -cout<<mom*1.2+jj<<Endl; -   return 0;  -}

I was reduced to writing this kind of brain problem.

Hhhhh

Well, + =-it's kinda fun.

"Luogu OJ" "C + +" level 1-2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.