Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用一个三维坐标#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator