1057 津津的储蓄计划
津津的零花钱一直都是自己管理。每个月的月初妈妈给津津300元钱,津津会预算这个月的花销,并且总能做到实际花销和预算的相同。
为了让津津学习如何储蓄,妈妈提出,津津可以随时把整百的钱存在她那里,到了年末她会加上20%还给津津。因此津津制定了一个储蓄计划:每个月的月初,在得到妈妈给的零花钱后,如果她预计到这个月的月末手中还会有多于100元或恰好100元,她就会把整百的钱存在妈妈那里,剩余的钱留在自己手中。
例如11月初津津手中还有83元,妈妈给了津津300元。津津预计11月的花销是180元,那么她就会在妈妈那里存200元,自己留下183元。到了11月月末,津津手中会剩下3元钱。
津津发现这个储蓄计划的主要风险是,存在妈妈那里的钱在年末之前不能取出。有可能在某个月的月初,津津手中的钱加上这个月妈妈给的钱,不够这个月的原定预算。如果出现这种情况,津津将不得不在这个月省吃俭用,压缩预算。
现在请你根据2004年1月到12月每个月津津的预算,判断会不会出现这种情况。如果不会,计算到2004年年末,妈妈将津津平常存的钱加上20%还给津津之后,津津手中会有多少钱。
输入包括12行数据,每行包含一个小于350的非负整数,分别表示1月到12月津津的预算。
输出包括一行,这一行只包含一个整数。如果储蓄计划实施过程中出现某个月钱不够用的情况,输出-X,X表示出现这种情况的第一个月;否则输出到2004年年末津津手中会有多少钱。
样例1:
290
230
280
200
300
170
340
50
90
80
200
60
样例2:
290
230
280
200
300
170
330
50
90
80
200
60
样例1:
-7
样例2:
1580
e
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int a[13],l,jjleft,momleft; double zong; int main() { for(int i=1;i<=12;i++) cin>>a[i]; for(int i=1;i<=12;i++) { l=300-a[i]; int temp=l; if(l>=100) { l/=100; momleft+=l*100; temp%=100; } jjleft+=temp; if(jjleft>=100) { momleft+=jjleft/100*100; jjleft=jjleft-(jjleft/100*100); } if(jjleft<0){ cout<<"-"<<i<<endl; return 0; } } zong=momleft*(1+0.2)+jjleft; cout<<zong<<endl; return 0; }
1275 有鱼的声音
A fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:
fish-finder是一个神奇的装置供垂钓者使用区在护理钓鱼。如果一个f-f找到了一条鱼,他会响起声音警报。它用鱼的深度来决定是否响警报。我们的目的就是要决定鱼是否通过,具体如下:
• there are four consecutive depth readings which form a strictly increasing sequence (such as 3 4 7 9) (which we will call “Fish Rising”), or
如果连续的四个深度读入是严格递增的序列,我们可以叫它 Fish Rising 。
• there are four consecutive depth readings which form a strictly decreasing sequence (such as 9 6 5 2) (which we will call “Fish Diving”), or
如果连续的四个深度读入是严格递减的序列,我们可以叫它 Fish Diving 。
• there are four consecutive depth readings which are identical (which we will call “Constant Depth”).
All other readings will be considered random noise or debris, which we will call “No Fish.”
Your task is to read a sequence of depth readings and determine if the alarm will sound.
如果连续的四个深度读入是一样的,那就是“Fish At Constant Depth”。如果都不是,就是“No Fish”。
The input will be four positive integers, representing the depth readings. Each integer will be on its own line of input.
输入会是四个正整数,代表深度读入。每个整数会占一行。
The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should be Fish At Constant Depth. Otherwise, the output should be No Fish.
输出就是四种情况。
样例1:
30 10 20 20
样例2:
1 10 12 13
样例1:
No Fish
样例2:
Fish Rising
数据很小
1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 using namespace std; 5 int main() 6 { 7 int a[5]; 8 for(int i=1;i<=4;i++) 9 cin>>a[i]; 10 if(a[1]<a[2]&&a[2]<a[3]&&a[3]<a[4]) 11 cout<<"Fish Rising"<<endl; 12 else if(a[1]==a[2]&&a[2]==a[3]&&a[3]==a[4]) 13 cout<<"Fish At Constant Depth"<<endl; 14 else if(a[1]>a[2]&&a[2]>a[3]&&a[3]>a[4]) 15 cout<<"Fish Diving"<<endl; 16 else 17 cout<<"No Fish"<<endl; 18 return 0; 19 }
1274 不好玩的罚金
Many communities now have “radar” signs that tell drivers what their speed is, in the hope that they will slow down.
许多社区现在有了雷达标志来告诉司机们他们的速度,以期待他们会减速。
You will output a message for a “radar” sign. The message will display information to a driver based on his/her speed according to the following table:
你要输出一个雷达标志的消息,这条消息会显示一个司机的速度和他要交的罚金的关系的信息,看下面的表格:
km/h over the limit Fine
1 to 20 $100
21 to 30 $270
31 or above $500
The user will be prompted to enter two integers. First, the user will be prompted to enter the speed limit. Second, the user will be prompted to enter the recorded speed of the car.
用户会输入2个整数。首先,用户会提供限速。然后,会输入车速的纪录。
If the driver is not speeding, the output should be:
Congratulations, you are within the speed limit
If the driver is speeding, the output should be:
You are speeding and your fine is $ F
where F is the amount of the fine as described in the table above
如果他没有超速,要输出Congratulations, you are within the speed limit
如果他超速,要输出You are speeding and your fine is $ F
F就是根据表格的描述计算出的罚金
Sample Session 1 (with output shown in text, user input in italics 只输入斜体)
Enter the speed limit: 40
Enter the recorded speed of the car: 39
Sample Session 2
Enter the speed limit:100
Enter the recorded speed of the car: 131
Sample Session 3
Enter the speed limit:100
Enter the recorded speed of the car: 120
Congratulations, you are within the speed limit
You are speeding and your fine is $ 500
You are speeding and your fine is $ 100
注意:“Enter the speed limit:”和“Enter the recorded speed of the car:”也是要输出的。所以完整的输出是:
(以第一个样例为参考)Enter the speed limit:Enter the recorded speed of the car:Congratulations, you are within the speed limit
输入描述一定会按照输入描述里的输入
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int v,v1,f,s; 6 7 int main() 8 { 9 cin>>v>>v1; 10 if(v1<=v) 11 cout<<"Enter the speed limit: Enter the recorded speed of the car: Congratulations, you are within the speed limit"<<endl; 12 else 13 { 14 s=v1-v; 15 if(s>=1&&s<=20) f=100; 16 if(s>=21&&s<=30) f=270; 17 if(s>=31) f=500; 18 cout<<"Enter the speed limit: Enter the recorded speed of the car: You are speeding and your fine is $ "<<f<<endl; 19 } 20 return 0; 21 }
1023 GPA计算
小松终于步入了大学的殿堂,带着兴奋和憧憬,他参加了信息科学技术学院的新生大会。会上,院长梅教授给大家介绍了在大学中的成绩计算方式:
需要解释一下的是,小松所在的PK大学采用的是学分制的修学方法。每一门课有一定的学分,例如线性代数2分,高等数学5分,大学英语8分。在选定了一些科目之后,只要小松通过了最后的期末测试(69以上),就会得到相应的学分,也会得到该门课的一个成绩,例如小松考了60分,他会得到0分的成绩,如果小松考了99分,他会得到4分的成绩。小松在大学的四年期间,必须修满145个学分。而小松的GPA得分则强烈的关系着他的出国,保研以及工作的情况。据梅教授的介绍,小松所在的院系有20%的人出国,60%的人读研,15%的人工作,5%的人退学。这些都是根据GPA成绩而定的。
小松仔细的研究了这个公式之后,意识到,在大学期间,占2个学分的思想政治课和占4个学分的线性代数将同等的重要。而占8个学分的大学英语课!·#¥!·#¥。
小松估算了一下他大一每门功课大概能够得到的分数(0-4),请你帮他计算一下他大一结束时能得到的GPA是多少。
请你从输入中读入相关数据。输入的第一行包括一个整数n(1≤n≤10),表示小松大一的时候功课数目。结下来的n行每行两个实数a(0≤a≤8)和b(0≤b≤4),表示小松某门课的学分和成绩。
输出只包括一个实数,请保留2位小数。
(请忽略括号中的解释)
10
2 3.7(线性代数)
0 3(线性代数习题)
5 3.7(高等数学)
0 4(高等数学习题)
3 3.3(力学)
3 4(计算概论)
1 4(信息科学技术概论)
2 4(军事理论)
2 4(中国近代史)
2 3.5(大学英语I)
3.74
n(1≤n≤10)
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int n,a[100],sum; 6 double m[100],ans,b[100]; 7 8 int main() 9 { 10 cin>>n; 11 for(int i=1;i<=n;i++) 12 { 13 cin>>a[i]>>b[i]; 14 sum+=a[i]; 15 } 16 for(int i=1;i<=n;i++) 17 { 18 m[i]=a[i]*b[i]; 19 m[i]/=sum; 20 ans+=m[i]; 21 } 22 printf("%.2lf",ans); 23 return 0; 24 }