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

打表,为什么会有误差啊啊啊啊啊啊啊啊啊啊啊

Posted by cockhorse at 2006-09-02 16:07:20 on Problem 2815
#include<stdio.h>
#include<math.h>
const int M=60*60*24;
int f[M];
int abs(int x)
{
	return x>0?x:-x;
}
int main()
{
	int s;
	double h,m,det;
	int sum,hh,mm,ss,cur;

	for(s=0;s<M;s++)
	{
		h=s/120.;
		while(h>=360) h-=360;
		m=s/10.;
		while(m>=360) m-=360;
		
		det=m-h;
		while(det<0) det+=360;

		f[s]=det;
	}
	while(scanf("%d %d:%d:%d",&sum,&hh,&mm,&ss),sum!=-1)
	{
		cur=hh*3600+mm*60+ss;
		while(1)
		{
			if (abs(f[cur]-sum)<1e-6) break;
			cur=(cur+1)%M;
		}
		printf("%02d:%02d:%02d\n",cur/3600,(cur%3600)/60,cur%60);
	}
	return 0;
}
ps:最后一个样例差1啊啊啊啊啊啊啊啊

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