1030 Delta-wave

#include <iostream>
#include "math.h"
using namespace std;


int Getn(int x)
{
 int t = int(sqrt(double(x)));
 if(t *t == x)
  t--;
 return t;
}
int main()
{
 int m,n;
 while(EOF != scanf("%d %d",&m,&n))//千万注意不只是一个输入,这里我就Wa了4次啊。本该1AC的。
 {
  int sn,sm,pn,pm;
  pn = Getn(n);
  pm = Getn(m);
  sn = pn*pn+1;
  sm = pm*pm+1;
  int sum =0;
  sum += abs((pn+1-(n-sn+1)/2)-(pm+1-(m-sm+1)/2));
  sum += abs((1+(n-sn)/2)-(1+(m-sm)/2));
  sum += abs((pn+1)-(pm+1));
  printf("%d\n",sum);
 }
 return 0;
}

你可能感兴趣的:(1030 Delta-wave)