暑假训练赛20160719
2016-07-19 14:42
288 查看
F--Hot or Cold?
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Submit Status
Description
John Smith, who is a member of Academy of Cold Manager (ACM), is in charge of a large-scale cold store. For him, it's a troublesome job. Whenever the temperature in the cold store is too hot or too cold for
a long time, the goods will be damaged. And poor Mr. Smith will have to compensate for the loss of the store.
Therefore, Mr. Smith has installed an automatic temperature control system in the store. The system may control the temperature according to the input polynomial and the start time. At each moment, it tries
to adjust the temperature equal to the value of the polynomial function. But Mr. Smith still feels worried. Since he could not know the effect beforehand how the system will regulate. At such a worrisome moment, it's lucky for him to call to remembrance that
you, an excellent programmer, are willing to offer a program to help him. Making use of this program, he may simply input the polynomial and the parameters of the start time and the end time, and then he will be aware of the average temperature during this
period. Now he is relieved from such a bothersome job.
Input
The input file may contain several data sets. Each data set begins with a line containing an integer n(n < 100), which specifies the highest
power of the polynomial. A value of 0 for the power indicates the end of input, and this data set should not be processed. In each data set, the following line contains n + 1 real numbers, which tell the coefficients of the
polynomial. The sequence of those coefficients is arranged according to the power of items from high to low in the polynomial. If an item of the polynomial does not exist, the corresponding coefficient is 0. And then follows a line consists of 2 real numbers s and e(s < e),
indicating the start time and the end time.
Output
For each data set, compute t, the average temperature of the input polynomial from the start time to the end time. Print your answer as a single real number accurate to 3 decimal
places on a line by itself. You should not print any more white spaces or blank lines in the output.
Sample Input
Sample Output
数学积分--
代码:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
double xi[120],s,kai,jie;
int main()
{
int n;
while (scanf("%d",&n),n)
{
for (int i=n+1;i>0;i--)
{
scanf("%lf",&xi[i]);
xi[i]/=i;
}
scanf("%lf%lf",&kai,&jie);
s=0.0;
for (int i=n+1;i>0;i--)
s+=xi[i]*(pow(jie,i)-pow(kai,i));
s/=(jie-kai);
printf("%.3lf\n",s);
}
return 0;
}
I - Digital Rivers
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
Submit Status
Description
A digital river is a sequence of numbers where the number following n is n plus the sum of its digits. For example, 12345 is followed by
12360, since 1 + 2 + 3 + 4 + 5 = 15. If the first number of a digital river is k we will call it river k.
For example, river 480 is the sequence beginning {480, 492, 507, 519,...} and river 483 is the sequence beginning {483, 498, 519,...}.
Normal streams and rivers can meet, and the same is true for digital rivers. This happens when two digital rivers share some of the same values. For example: river 480 meets river 483 at 519, meets river 507
at 507, and never meets river 481.
Every digital river will eventually meet river 1, river 3 or river 9. Write a program that can determine for a given integer n the value where river n first
meets one of these three rivers.
Input
The input may contain multiple test cases. Each test case occupies a separate line and contains an integer n(1
n
16384).
A test case wit h value of 0 for n terminates the input and this test case must not be processed.
Output
For each test case in the input first output the test case number (starting from 1) as shown in the sample output. Then on a separate line output the line ``first meets river x at y".
Here y is the lowest value where river n first meets river x (x = 1 or 3 or 9). If river nmeets
river x at y for more than one value of x, output the lowest value.
Print a blank line between two consecutive test cases.
Sample Input
Sample Output
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MA 100000100
int he[MA];
int ji(int xx)
{
int lp,jia;
lp=xx;jia=0;
while (xx)
{
jia+=xx%10;
xx/=10;
}
lp+=jia;
return lp;
}
int main()
{
memset(he,0,sizeof(he));
int shu;
shu=9;
while (shu<MA)
{
he[shu]=9;
shu=ji(shu);
}
shu=3;
while (shu<MA)
{
he[shu]=3;
shu=ji(shu);
}
shu=1;
while (shu<MA)
{
he[shu]=1;
shu=ji(shu);
}
int n,lp=1;
while (scanf("%d",&n),n)
{
if (lp>1)
printf("\n");
printf("Case #%d\n",lp++);
while (n)
{
if (he
)
{
printf("first meets river %d at %d\n",he
,n);
break;
}
n=ji(n);
if (n>MA)
{
printf("%d 66",n);
break;
}
}
}
return 0;
}
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Submit Status
Description
John Smith, who is a member of Academy of Cold Manager (ACM), is in charge of a large-scale cold store. For him, it's a troublesome job. Whenever the temperature in the cold store is too hot or too cold for
a long time, the goods will be damaged. And poor Mr. Smith will have to compensate for the loss of the store.
Therefore, Mr. Smith has installed an automatic temperature control system in the store. The system may control the temperature according to the input polynomial and the start time. At each moment, it tries
to adjust the temperature equal to the value of the polynomial function. But Mr. Smith still feels worried. Since he could not know the effect beforehand how the system will regulate. At such a worrisome moment, it's lucky for him to call to remembrance that
you, an excellent programmer, are willing to offer a program to help him. Making use of this program, he may simply input the polynomial and the parameters of the start time and the end time, and then he will be aware of the average temperature during this
period. Now he is relieved from such a bothersome job.
Input
The input file may contain several data sets. Each data set begins with a line containing an integer n(n < 100), which specifies the highest
power of the polynomial. A value of 0 for the power indicates the end of input, and this data set should not be processed. In each data set, the following line contains n + 1 real numbers, which tell the coefficients of the
polynomial. The sequence of those coefficients is arranged according to the power of items from high to low in the polynomial. If an item of the polynomial does not exist, the corresponding coefficient is 0. And then follows a line consists of 2 real numbers s and e(s < e),
indicating the start time and the end time.
Output
For each data set, compute t, the average temperature of the input polynomial from the start time to the end time. Print your answer as a single real number accurate to 3 decimal
places on a line by itself. You should not print any more white spaces or blank lines in the output.
Sample Input
2 1.0 0.0 0.0 0.0 1.0 0
Sample Output
0.333
数学积分--
代码:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
double xi[120],s,kai,jie;
int main()
{
int n;
while (scanf("%d",&n),n)
{
for (int i=n+1;i>0;i--)
{
scanf("%lf",&xi[i]);
xi[i]/=i;
}
scanf("%lf%lf",&kai,&jie);
s=0.0;
for (int i=n+1;i>0;i--)
s+=xi[i]*(pow(jie,i)-pow(kai,i));
s/=(jie-kai);
printf("%.3lf\n",s);
}
return 0;
}
I - Digital Rivers
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
Submit Status
Description
A digital river is a sequence of numbers where the number following n is n plus the sum of its digits. For example, 12345 is followed by
12360, since 1 + 2 + 3 + 4 + 5 = 15. If the first number of a digital river is k we will call it river k.
For example, river 480 is the sequence beginning {480, 492, 507, 519,...} and river 483 is the sequence beginning {483, 498, 519,...}.
Normal streams and rivers can meet, and the same is true for digital rivers. This happens when two digital rivers share some of the same values. For example: river 480 meets river 483 at 519, meets river 507
at 507, and never meets river 481.
Every digital river will eventually meet river 1, river 3 or river 9. Write a program that can determine for a given integer n the value where river n first
meets one of these three rivers.
Input
The input may contain multiple test cases. Each test case occupies a separate line and contains an integer n(1
n
16384).
A test case wit h value of 0 for n terminates the input and this test case must not be processed.
Output
For each test case in the input first output the test case number (starting from 1) as shown in the sample output. Then on a separate line output the line ``first meets river x at y".
Here y is the lowest value where river n first meets river x (x = 1 or 3 or 9). If river nmeets
river x at y for more than one value of x, output the lowest value.
Print a blank line between two consecutive test cases.
Sample Input
86 12345 0
Sample Output
Case #1 first meets river 1 at 101 Case #2 first meets river 3 at 12423
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MA 100000100
int he[MA];
int ji(int xx)
{
int lp,jia;
lp=xx;jia=0;
while (xx)
{
jia+=xx%10;
xx/=10;
}
lp+=jia;
return lp;
}
int main()
{
memset(he,0,sizeof(he));
int shu;
shu=9;
while (shu<MA)
{
he[shu]=9;
shu=ji(shu);
}
shu=3;
while (shu<MA)
{
he[shu]=3;
shu=ji(shu);
}
shu=1;
while (shu<MA)
{
he[shu]=1;
shu=ji(shu);
}
int n,lp=1;
while (scanf("%d",&n),n)
{
if (lp>1)
printf("\n");
printf("Case #%d\n",lp++);
while (n)
{
if (he
)
{
printf("first meets river %d at %d\n",he
,n);
break;
}
n=ji(n);
if (n>MA)
{
printf("%d 66",n);
break;
}
}
}
return 0;
}
相关文章推荐
- 1.虚函数的继承与派生;2.多文件静态对象的定义顺序,3模板注意,4mysql二、十六进制, 4颜色名称,5QSvgRenderer真实rect和viewboxrect转换
- ubuntu16.04 安装Hadoop2.7.2
- 分配空间的三种函数——malloc,calloc,realloc
- Android中定时器Timer和TimerTask的启动,停止,暂停,继续等操作实例
- Java逐行读写TXT文件
- python对redis的常用操作 上 (对列表、字符串、散列结构操作)
- Font Awesome字体图标
- GreenDao_2.介绍GreenDao
- 为自己建立一个好的企业构思
- mongo模糊查询
- linux下面ln -s软连接(No package 'libxml-2.0' found)
- python概述
- 第七次迭代开发总结(AngularJS下文件上传的实现)
- debug 指令
- sketch工具自学介绍
- 数据库
- Maven:mirror和repository 区别
- Android开发技术周报 Issue#33
- QT TAB键跳转
- Memory Map(Linux 存储映射IO)