77范文网 - 专业文章范例文档资料分享平台

整理的-----ACM题目及答案(3)

来源:网络收集 时间:2018-12-04 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

sum+=5; }

printf(\,sum); }

return 0;

}

1009 FatMouse' Trade

Problem Description

FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.

The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get J[i]* a% pounds of JavaBeans if he pays F[i]* a% pounds of cat food. Here a is a real number. Now he is assigning this homework to you: tell him the maximum amount of JavaBeans he can obtain.

Input

The input consists of multiple test cases. Each test case begins with a line containing two non-negative integers M and N. Then N lines follow, each contains two non-negative integers J[i] and F[i] respectively. The last test case is followed by two -1's. All integers are not greater than 1000.

Output

For each test case, print in a single line a real number accurate up to 3 decimal places, which is the maximum amount of JavaBeans that FatMouse can obtain.

Sample Input

5 3 7 2 4 3 5 2 20 3 25 18 24 15 15 10 -1 -1

Sample Output

13.333 31.500

Author

CHEN, Yue

Source

ZJCPC2004

Recommend

JGShining

11

代码:

#include #include #define MAX 1000 int main() {

int i,j,m,n,temp;

int J[MAX],F[MAX]; double P[MAX]; double sum,temp1;

scanf(\ while(m!=-1&&n!=-1) {

sum=0;

memset(J,0,MAX*sizeof(int));

memset(F,0,MAX*sizeof(int)); memset(P,0,MAX*sizeof(double));

for(i=0;i

for(j=i+1;j

if(P[i]

temp1=P[i]; P[i]=P[j]; P[j]=temp1; temp=J[i]; J[i]=J[j]; J[j]=temp; temp=F[i]; F[i]=F[j]; F[j]=temp; } }

}

for(i=0;i

{

if(m

printf(\ scanf(\ }

return 0; }

12

1021 Fibonacci Again

Problem Description

There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).

Input

Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000).

Output

Print the word \Print the word \

Sample Input

0 1 2 3 4 5

Sample Output

no no yes no no no

Author

Leojay

Recommend

JGShining

#include int main() {

long n;

while(scanf(\,&n) != EOF) if (n%8==2 || n%8==6) printf(\); else

printf(\);

13

return 0; }

1089 A+B for Input-Output Practice

(I)

Problem Description

Your task is to Calculate a + b.

Too easy?! Of course! I specially designed the problem for acm beginners.

You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.

Input

The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.

Output

For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.

Sample Input

1 5 10 20

Sample Output

6 30

Author

lcy

Recommend

JGShining

解答:

#include main() {

14

int a,b;

while(scanf(\,&a,&b)!=EOF) printf(\,a+b); }

1090 A+B for Input-Output Practice

(II)

Problem Description

Your task is to Calculate a + b.

Input

Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line.

Output

For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.

Sample Input

2 1 5 10 20

Sample Output

6 30

Author

lcy

Recommend

JGShining

解答:

#include #define M 1000 void main()

15

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库整理的-----ACM题目及答案(3)在线全文阅读。

整理的-----ACM题目及答案(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/339456.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: