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 dou116703623 at 2009-03-04 20:11:40 on Problem 2619
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int p1,q1,p2,q2,p3,q3;
	int y1,y2;
	int m,n;
	int xiangshu;
	int ans;
	cin>>m>>n;
	int i;
	for(i=1;;i=i+2)
	{
		xiangshu=(i+1)/2;
		p1=(1+i)*xiangshu/2;
		if(p1>=m) {p1=xiangshu;break;}
	}
	for(i=1;;i=i+2)
	{
		xiangshu=(i+1)/2;
		q1=(1+i)*xiangshu/2;
		if(q1>=n) {q1=xiangshu;break;}
	}
	p2=m-(p1-1)*(p1-1);
	q2=n-(q1-1)*(q1-1);
	p2=(p2+1)/2;
	q2=(q2+1)/2;
	p3=p1*p1-m;
	q3=q1*q1-n;
	p3=p3/2;
	q3=q3/2;
	ans=abs(p1-q1)+abs(p2-q2)+abs(p3-q3);
	cout<<ans<<endl;
	system("pause");
	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