| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3775 人关注过本帖
标题:[讨论]]第十一期编程题目(题目很简单,大家一起来做了)
只看楼主 加入收藏
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
 问题点数:0 回复次数:46 
[讨论]]第十一期编程题目(题目很简单,大家一起来做了)
第一题:

青蛙的约会
Time Limit:1000MS Memory Limit:10000K
Total Submit:16233 Accepted:1839

Description
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。
我们把这两只青蛙分别叫做青蛙A和青蛙B,并且规定纬度线上东经0度处为原点,由东往西为正方向,单位长度1米,这样我们就得到了一条首尾相接的数轴。设青蛙A的出发点坐标是x,青蛙B的出发点坐标是y。青蛙A一次能跳m米,青蛙B一次能跳n米,两只青蛙跳一次所花费的时间相同。纬度线总长L米。现在要你求出它们跳了几次以后才会碰面。

Input
输入只包括一行5个整数x,y,m,n,L,其中x≠y < 2000000000,0 < m、n < 2000000000,0 < L < 2100000000。

Output
输出碰面所需要的跳跃次数,如果永远不可能碰面则输出一行"Impossible"

Sample Input

1 2 3 4 5

Sample Output

4





搜索更多相关主题的帖子: FONT 青蛙 题目 Limit color 
2007-04-12 21:09
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

Exponentiation
Time Limit:500MS Memory Limit:10000K
Total Submit:19808 Accepted:4475

Description
Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems.

This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.

Input
The input will consist of a set of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 and 9.

Output
The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don't print the decimal point if the result is an integer.

Sample Input

95.123 12
0.4321 20
5.1234 15
6.7592  9
98.999 10
1.0100 12

Sample Output

548815620517731830194541.899025343415715973535967221869852721
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
43992025569.928573701266488041146654993318703707511666295476720493953024
29448126.764121021618164430206909037173276672
90429072743629540498.107596019456651774561044010001
1.126825030131969720661201
简单翻译一下:
其实是一个高精度计算.计算R的N次方,不能忽略任何有效数字

2007-04-12 21:20
I喜欢c
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:64
帖 子:1749
专家分:0
注 册:2007-3-2
收藏
得分:0 

晕!
你也太急了不是....


 我是指针,却丢失了目标地址!          我是循环,却缺少了结束条件!      我是函数,却没有人来调用!   
2007-04-12 22:00
iwfy
Rank: 1
等 级:新手上路
威 望:2
帖 子:888
专家分:0
注 册:2007-2-23
收藏
得分:0 
青蛙要约会能不急吗,跳的那么慢,现在网友见面都坐火车呢

英语不好还想学编程??逆天之路,不由分说!! 数学太差还想学编程??离经叛道,义无返顾!!
2007-04-12 22:21
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
以下是引用I喜欢c在2007-4-12 22:00:07的发言:

晕!
你也太急了不是....

我也不想.我一怕我自己忘了.二怕这次又没有几个做,所以特意找两个简单的乘快要周末了.看能不能混点人气.
哎.
现在都不知道哪些题目符合大家的胃口


2007-04-12 22:56
I喜欢c
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:64
帖 子:1749
专家分:0
注 册:2007-3-2
收藏
得分:0 

找一些对底沉硬件操作的....


 我是指针,却丢失了目标地址!          我是循环,却缺少了结束条件!      我是函数,却没有人来调用!   
2007-04-12 23:15
高达
Rank: 1
等 级:新手上路
威 望:1
帖 子:261
专家分:0
注 册:2006-10-27
收藏
得分:0 

现在有人约会都 坐 原子弹了


哎 时间....................
2007-04-12 23:28
moonwalker
Rank: 1
等 级:新手上路
威 望:1
帖 子:909
专家分:2
注 册:2007-3-2
收藏
得分:0 

这次题目果然简单,第一题几分钟就可以搞定,明天回来再做第二题
#include "stdio.h"
main()
{
long x,y,m,n,L;
long a,b;
int i=0,flag=0;
int Judge(long x,long y,long m,long n,long L);
do{
printf("Input x,y,m,n,L:\n");
scanf("%ld,%ld,%ld,%ld,%ld",&x,&y,&m,&n,&L);
}while(Judge(x,y,m,n,L)==0);
a=x;
b=y;
while(flag==0)
{
i++;
a=(a+m)%L;
b=(b+n)%L;
if(a==b)
flag=1;
if(a==x && b==y)
flag=2;
}
if(flag==1)
printf("The times is %d\n",i);
else if(flag==2)
printf("Impossible!\n");
}
int Judge(long x,long y,long m,long n,long L)
{
int r=1;
if(x==y)
{
printf("Two frogs are not at a place!(x!=y) Another input please!\n");
r=0;
}
else if(x>=2000000000 || y>=2000000000 || m>=2000000000 || n>=2000000000)
{
printf("Invalid input! Another input please!\n");
r=0;
}
else if(x<=0 || y<=0 || m<=0 || n<=0)
{
printf("Invalid input! Another input please!\n");
r=0;
}
else if(L<=0 || L>=2100000000)
{
printf("Invalid input! Another input please!\n");
r=0;
}
else if(x>L || y>L)
{
printf("Invalid input! Another input please!\n");
r=0;
}
return r;
}


“视频教程网”免费提供教学资源
C不限制你的自由!
条件是自己承担滥用自由的恶果!
2007-04-13 00:14
yu_hua
Rank: 2
等 级:论坛游民
帖 子:222
专家分:95
注 册:2006-8-10
收藏
得分:0 
#include <stdio.h>
#include <stdlib.h>
long gcd(long u,long v)
{
return v?gcd(v,u%v):u;/*最大公约数*/
}
main()
{
long x,y,m,n,L,step=0,t;
printf("Input x,y,m,n,L:\n");
scanf("%ld,%ld,%ld,%ld,%ld",&x,&y,&m,&n,&L);
if(x==y||m==n)abort();
if(m<n)t=m,m=n,n=t,t=x,x=y,y=t;
t=gcd(L,m-n);
if((x-y)%t==0)
while(++step)
{
x=(x+m)%L;
y=(y+n)%L;
if(x==y)break;
}
if(step)printf("%ld\n",step);
else printf("Impossible!\n");
}

[此贴子已经被作者于2007-4-14 9:06:53编辑过]

2007-04-13 08:40
vcj菜鸟
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-4-8
收藏
得分:0 
都这么熟练哇....
2007-04-13 08:45
快速回复:[讨论]]第十一期编程题目(题目很简单,大家一起来做了)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017456 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved