杭电acmelevator问题c语言答案,杭电ACM部分题答案.doc

44cb7578e1df5412b94317daaa3307ba.gif杭电ACM部分题答案.doc

下载提示(请认真阅读)1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。

2.下载的文档,不会出现我们的网址水印。

3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。

文档包含非法信息?点此举报后获取现金奖励!

下载文档到电脑,查找使用更方便

12

积分

还剩页未读,继续阅读

关 键 词:ACM

部分

答案

资源描述:

1000A + B Problem

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 158161Accepted Submission(s): 50186

Problem Description

Calculate A + B.

Input

Each line will contain two integers A and B. Process to end of file.

Output

For each case, output A + B in one line.

Sample Input

1 1

Sample Output

2

Author

HDOJ

Statistic|Submit|Discuss | Note

#includeint main()

{

int a,b;

while(scanf("%d %d",&a,&b)!=EOF)

printf("%d\n",a+b);

}

1002A + B Problem II

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 84367Accepted Submission(s): 15966

Problem Description

I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.

Input

The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.

Output

For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.

Sample Input

2

1 2

112233445566778899 998877665544332211

Sample Output

Case 1:

1 + 2 = 3

Case 2:

112233445566778899 + 998877665544332211 = 1111111111111111110

Author

Ignatius.L

Statistic|Submit|Discuss | Note

#include #include int main(){

char str1[1001], str2[1001];

int t, i, len_str1, len_str2, len_max, num = 1, k;

scanf("%d", &t);

getchar();

while(t--){

int a[1001] = {0}, b[1001] = {0}, c[1001] = {0};

scanf("%s", str1);

len_str1 = strlen(str1);

for(i = 0; i <= len_str1 - 1; ++i)

a[i] = str1[len_str1 - 1 - i] - 0;

scanf("%s",str2);

len_str2 = strlen(str2);

for(i = 0; i <= len_str2 - 1; ++i)

b[i] = str2[len_str2 - 1 - i] - 0;

if(len_str1 > len_str2)

len_max = len_str1;

else

len_max = len_str2;

k = 0;

for(i = 0; i <= len_max - 1; ++i){

c[i] = (a[i] + b[i] + k) % 10;

k = (a[i] + b[i] + k) / 10;

}

if(k != 0)

c[len_max] = 1;

printf("Case %d:\n", num);

num++;

printf("%s + %s = ", str1, str2);

if(c[len_max] == 1)

printf("1");

for(i = len_max - 1; i >= 0; --i){

printf("%d", c[i]);

}

printf("\n");

if(t >= 1)

printf("\n");

}

return 0;

}

1005Number Sequence

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 44346Accepted Submission(s): 9722

Problem Description

A number sequence is defined as follows:

f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.

Given A, B, and n, you are to calculate the value of f(n).

Input

The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 <= A, B <= 1000, 1 <= n <= 100,000,000). Three zeros signal the end of input and this test case is not to be processed.

Output

For each test case, print the value of f(n) on a single line.

Sample Input

1 1 3

1 2 10

0 0 0

Sample Output

2

5

Author

CHEN, Shunbao

Source

ZJCPC2004

Recommend

JGShining

Statistic|Submit|Discuss | Note

#includeint f[200];

int main()

{

int a,b,n,i;

while(scanf("%d%d%d",&a,&b,&n)&&a&&b&&n)

{

if(n>=3)

{

f[1]=1;f[2]=1;

for(i=3;i<=200;i++)

{

f[i]=(a*f[i-1]+b*f[i-2])%7;

if(f[i-1]==1&&f[i]==1)

break;

}

i-=2;

n=n%i;

if(n==0)

printf("%d\n",f[i]);

else

printf("%d\n",f[n]);

}

else

printf("1\n");

}

return 0;

}

1008Elevator

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 17764Accepted Submission(s): 9490

Problem Description

The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.

For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled.

Input

There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.

Output

Print the total time on a single line for each test case.

Sample Input

1 2

3 2 3 1

0

Sample Output

17

41

Author

ZHENG, Jianqiang

Source

ZJCPC2004

Recommend

JGShining

Statistic|Submit|Discuss | Note

#includeint a[110];

int main()

{

int sum,i,n;

while(scanf("%d",&n)&&n!=0)

{

for(i=1;i<=n;i++)

scanf("%d",&a[i]);

sum=0;

a[0]=0;

for(i=1;i<=n;i++)

{

if(a[i]>a[i-1])

sum+=6*(a[i]-a[i-1]);

else

sum+=4*(a[i-1]-a[i]);

sum+=5;

}

printf("%d\n",sum);

}

return 0;

}

1021Fibonacci Again

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 15856Accepted Submission(s): 7456

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 "yes" if 3 divide evenly into F(n).

Print the word "no" if not.

Sample Input

0

1

2

3

4

5

Sample Output

no

no

yes

no

no

no

Author

Leojay

Recommend

JGShining

#includeint main()

{

long n;

while(scanf("%ld",&n) != EOF)

if (n%8==2 || n%8==6)

printf("yes\n");

else

printf("no\n");

return 0;

}

展开阅读全文

温馨提示:

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。

2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。

3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。

4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。

5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。

6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。

7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

bb6249c6567dd4384e6ab3556cfc22ed.gif 

人人文库网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。

关于本文

本文标题:杭电ACM部分题答案.doc

链接地址:https://www.renrendoc.com/p-38832399.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值