数学+找规律题

来源:互联网 发布:net dvr监控软件下载 编辑:程序博客网 时间:2024/04/26 08:44

今天,打了一场比赛,心情不是很好。为什么总是进步的那么慢。

主要也许是心静不下来。懒得看题目,想着别人肯定也不会做然后自己也懒得去动。

所以我想我要好好反思一下。

 A题:Money , money(主要是英文写的,然后理解题目意思有点想了半天,然后一开始没想到其实只要取每个月最大的利润就好了,所以卡了半天。)

Small K seen recently stock market really too violent, so he want to choose some ways to earn money.

At every month, he can use three ways to manage his money . For example , if he has 1000 dollars , At first month,

he can use 500 for A way , 300 for B way, and 200 just do nothing.  After first month , he will get X1 / 100 * 500 + y1 / 100 * 300 money.

Then he can use this money to invest in later months.

So the question is :

The total money he can earn after investing.  (Earn money not the early money + earn money)

以上都不重要,除了最后一句,告诉我们挣得的钱是要减掉原先的钱的。

输入

The first number n means that there are n cases.

next n cases' format will be that

the first line has 12 real number , means X way's profit x1% in every month

the second line has 12 real number ,means Y way's profit y1% in every month

the third line has 12 real number , means Z way's profit z1% in every month

the forth line is a double x,which means the original money small K has.

输出

Every case ,you output a real number , means the profit Small K can get. (returned three decimal places)

样例输入

13.1 3.2 3.2 3.1 3.4 3.0 2.9 3.8 3.5 3.0 3.2 4.010.1 10.2 10.3 10.4 10.5 10.6 10.7 10.7 10.9 11.0 11.1 11.215.0 -3.0 -10.0 30.0 20.0 10.0 0.0 -12.0 -9.0 20.0 30.0 -23.010000.0

样例输出

#include<stdio.h>#include<string.h>double max(double a,double b,double c){double t=a;if(t<b)  t=b;if(t<c)  t=c; return t;}int main(){int n;double x[13],y[13],z[13],max1,sum,t;scanf("%d",&n);while(n--){memset(x,0,sizeof(x)); memset(y,0,sizeof(y)); memset(z,0,sizeof(z));for(int i=1;i<=12;i++)scanf("%lf",&x[i]);for(int i=1;i<=12;i++)scanf("%lf",&y[i]);for(int i=1;i<=12;i++)scanf("%lf",&z[i]);scanf("%lf",&sum);t=sum;for(int i=1;i<=12;i++){max1=max(x[i],y[i],z[i]);sum=sum*(1.0+max1/100.0);}printf("%.3lf\n",sum-t);}}


C题:Sum?Sum!

Kid want to learn math better.Now Kid know how to calculate the sum of 1 to n in a short time.But this time,he is given a much more difficult question——to calculate the sum of 1 to 10^n.Kid think for a long time——10^10 ms and then he solve the question successfully.

Do you know how to solve it ?

输入

The first line is a integer t(1<=t<=10),indicate the number of case.

For each t,there is a integer n(the meaning of n is in the above),0<=n<=10^4.

输出

For each case,just print the answer of the sum.

实质就是让你计算10的n次幂,然后再求和。

一开始我看到n最大值竟然有10^4,然后我就想是不是要用快速幂,但是题目又没说要取摸,而且也没给值。后来又想到了以前做过的大数求和时用字符串来输出,但是这里如果用字符串来输出的话长度最多有10^4,那用for输出的话好像也是不行的。

后来别人告诉我了怎么去做,就是找规律,把n=0到n=3写出来就会有规律了,后来我发现了,n=0时是特判,然后后面是5(n-1)5(n-1),这里的n-1代表的是0的个数,所以输出的时候就很简单了。

#include<stdio.h>int main(){int t,i,sum,n;scanf("%d",&t);while(t--){scanf("%d",&n);if(n==0) printf("1");else {printf("5");for(i=1;i<n;i++)printf("0");printf("5");for(i=1;i<n;i++)printf("0");}printf("\n");}}

J题:Eliminate zero AC

题目描述

Last night,Kid submitted a problem for many times but he got many WA,so he is sad.Out of

sympathy, his coach gave him a very simple problem so that Kid can solve it quickly. The problem

is to select as many numbers as possible range 1 to n so that among these selected number there

are no number can be divided exactly by other number. Can you solve it as quick as Kid?

输入

There are multiple cases.

For each case, there is a integer n(1<=n<=10^9)

输出

For each case,just output the answer.(the most numbers you can select)

提示

You can select {2,3,5} or {3,4,5}... but you can’t select {2,3,4,5} because 2|4.

So the answer is 3.

这道题意思是选择尽可能多的数,使这些数没有一个数可以被其他数整除。

思路:

当为奇数个时,个数为奇数个+1再除以2;

当为偶数个时,个数为偶数直接除以2;

虽然我不是很懂。

0 0
原创粉丝点击