Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1983
The question about the power of the complex number, first of all, from the geometric point of view, a complex can be rotated counterclockwise around the Origin K*arctan (b/a) time after the real number? (The geometrical properties of a complex power)
(Here is a special sentence, when a=0, obviously, n=2)
To do this, arctan (b/a) must be a rational number, and this article shows that this is true if and only if b/a∈{-1,0,1}.
So, as long as the judge b/a whether ∈{-1,0,1} on the line, the others are too complicated.
Complete code:
01./*0.013s*/
.
#include <cstdio>
#include <cstdlib>
.
06.int Main ()
07.{
An int T, a, B; scanf ("%d", &t);
While (t--)
. { scanf ("%d%d", &a, &b); if (b = = 0) puts ("1");
/ Else if (a = = 0) puts ("2"); Else if (abs (a) = = ABS (b)) puts ("4"); else puts ("TOO complicated");
. return 0;
19.}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/