如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。
URAL/1302
来自"NOCOW"
< URAL
狗眼观察。
#include <iostream> #include <cmath> using namespace std; int n,m,x1,x2,y11,y2,l,r,ans; inline int sqr(int x) { return x*x; } int main() { cin >> m >> n; if (m > n) swap(m,n); x1=(int)sqrt((double)m); if (m > sqr(x1)) ++x1; x2=(int)sqrt((double)n); if (n > sqr(x2)) ++x2; y11=m-sqr(x1-1); y2=n-sqr(x2-1); if (x1 < x2) { ans=(x2-x1-1<<1); if (y11&1^1) { ++ans; l=y11; r=y11+(x2-x1<<1); } else { l=y11+1; r=y11+(x2-x1<<1)-1; } ++ans; if (y2 < l) ans+=l-y2; if (r < y2) ans+=y2-r; if ((y2 > l) && (y2 < r) && (y2&1)) ++ans; } else ans=y2-y11; cout << ans << endl; return 0; } //by zzy