Sqrt Bo
.
.
给出一个数,问这个数进行不超过5次开根下取整能否变为1。
.
.
只有5次,直接算就好了。
.
#include <cstdio>
#include <cstring>
#include <cmath>
char a[1000];
int main()
{
while (~scanf("%s", a))
{
if (strlen(a) > 16)
{
printf("TAT\n");
continue;
}
else
{
long long p = 0;
for (int i = 0; i < strlen(a); i++)
{
p = p * 10 + a[i] - '0';
}
if (p == 0)
{
printf("TAT\n");
continue;
}
if (p == 1)
{
printf("0\n");
continue;
}
bool ok = false;
for (int i = 1; i <= 5; i++)
{
p = (long long)sqrt(p);
if (p == 1)
{
printf("%d\n", i);
ok = true;
break;
}
}
if (!ok) printf("TAT\n");
}
}
}