Uva--10161 (数学)
2014-06-07 18:08:30
题意&思路:简单题,没啥好说。(没用long long竟然也AC了,嘿嘿~本来想改的更鲁棒的,懒得敲了。。)
#include <cstdio> #include <cmath> #include <iostream> using namespace std; int main(){ int n,i,t; while(scanf("%d",&n) == 1 && n){ i = (int)(sqrt(n)); if(i * i == n) --i; t = n - i * i; if((i + 1) & 1){//最外圈为奇数圈 if(t <= i + 1){ printf("%d %d\n",i + 1,t); } else{ printf("%d %d\n",2 * i + 2 - t, i + 1); } } else{//最外圈为偶数圈 if(t <= i + 1){ printf("%d %d\n",t,i + 1); } else{ printf("%d %d\n",i + 1,2 * i + 2 - t); } } } return 0; }