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:我的程序为什么是wrong answer 啊?恳请高手赐教啊!

Posted by Jack2011 at 2011-06-29 00:46:37 on Problem 1005
In Reply To:我的程序为什么是wrong answer 啊?恳请高手赐教啊! Posted by:992913926 at 2011-06-06 22:58:43
> 我的思路是PI/2*(Rn*Rn)-PI/2*(Rn-1*Rn-1)=50;然后迭代,Rn=sqrt(100/PI+Rn-1*Rn-1); 当Rn>d是就结束了。我的代码中now next分别代表Rn Rn-1
> 运行结果没错啊!我的很多同学不知道我的程序为什么错了!我大二。谢谢指点啊!
> 
> #include<iostream>
> #include<cmath>
> #define PI 3.1415926
> using namespace std;
> 
> int main()
> {
>   float next,num=0,now,x,y,d;
>   int T,year;
>  next=now=0;
>   cin>>T;
>     
> 	do
> 	{
> 		++num;
> 		year=1;
>         cin>>x>>y;
> 		d=sqrt(x*x+y*y);
> 		while(next<d)
> 		{
> 		  next=sqrt(100/PI+now*now);
> 		  if(next>d)
> 		    break;
> 		  else
> 			  ++year;
> 		  now=next;
> 		}	  
> 	   cout<<"Property "<<num<<": This property will begin eroding in year "<<year<<"."<<endl;
> 	}while(--T);
> 
> 	cout<<"END OF OUTPUT."<<endl;
>      
> 	return 0;
> }

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