Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:错误的方法

Posted by 2008624 at 2009-08-14 14:16:21 on Problem 1061
In Reply To:不好意思,本人没帮你解决问题,还给你增添了麻烦,这是我的程序(C++版) Posted by:happy8860 at 2007-04-05 16:02:32
> 不好意思,本人没帮你解决问题,还给你增添了麻烦
> 
> 
> #include<iostream>
> 
> const long MaxXY=2000000000;
> const long MaxVAB=2000000000;
> const long MaxL=2100000000;
> bool isMeet(long x,long y,long VA,long VB,long L,long &t);  /*判断能否相见,如果能,用t返回相见时跳的次数*/
> using namespace std;
> void main()
> {
> 	long x,y,VA,VB,L,N;
> 	cout<<"输入青蛙A和青蛙B位置x,y,速度VA,VB和纬线总长L,以第一个数目非法时结束"<<endl;
> 	if(!(cin>>x))return;
> 	while(x>=0&&x<=MaxXY)
> 	{
> 		if(!(cin>>y>>VA>>VB>>L))return;
> 		if(y<0||x==y||y>MaxXY||VA<0||VA>MaxVAB||VB<0||VB>MaxVAB||L<0||L<=x||L<=y||L>MaxL)//判断输入
> 			cout<<"错误!请重新输入!"<<endl;
> 		else
> 		{
> 			if(isMeet(x,y,VA,VB,L,N))cout<<"这两只青蛙会见面的,见面时他们跳了"<<N<<"次"<<endl;
> 			else cout<<"很遗憾,他们这样不可能见面的!"<<endl;
> 		}
> 		cout<<"输入青蛙A和青蛙B位置x,y,速度VA,VB和纬线总长L,以第一个数目非法时结束"<<endl;
> 		if(!(cin>>x))return;
> 	}
> }
> 
> bool isMeet(long x,long y,long VA,long VB,long L,long &N)/*判断能否相见,如果能,用t返回相见时跳的次数*/
> {
> 	N=L;
> 	for(int i=1;i<N;i++)
> 		if(((VA-VB)*i+(x-y))%L==0)
> 		{N=i;break;}
> 	if(N!=L)return true;
> 	return false;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator