poj1730
来源:互联网 发布:深圳蛇口招商网络 编辑:程序博客网 时间:2024/05/23 19:16
//刚开始忘了考虑 testNum的正负号问题(负数的哪有次方啊),
#include<stdio.h>
#include<math.h>
#define minNum 1e-12
int main()
{
long long testNum;
int step;
double ans,minTestNum,maxTestNum;
while(scanf("%lld",&testNum),testNum)
{
if(testNum>0)
for(step=32; step>0; step--)
{
ans=pow(testNum*1.0,1.0/step);
minTestNum=floor(ans);
maxTestNum=ceil(ans);
if(fabs(minTestNum-ans)<minNum||fabs(maxTestNum-ans)<minNum)
{
printf("%d\n",step);
break;
}
}
else
{
testNum=-testNum;
for(step=31; step>0; step-=2)
{
ans=pow(testNum*1.0,1.0/step);
minTestNum=floor(ans);
maxTestNum=ceil(ans);
if(fabs(minTestNum-ans)<minNum||fabs(maxTestNum-ans)<minNum)
{
printf("%d\n",step);
break;
}
}
}
}
return 0;
}
- poj1730
- poj1730
- poj1730
- poj1730 - Perfect Pth Powers
- poj1730(数学)
- POJ2909&&POJ1730基础数论
- 【数论】poj1730 Perfect Pth Powers
- POJ1730 Perfect Pth Powers (math)
- poj1730——Perfect Pth Powers
- poj1730--Perfect Pth Powers
- ACM: 一道数论题 poj1730 (做了好…
- linux 创建新账号 useradd 命令使用
- 说说JSON和JSONP,也许你会豁然开朗
- Torque/MPI调度环境简介
- dumpAllThreads挂起程序的问题
- SQL SERVER的Select赋值,是循环赋值
- poj1730
- 大数据量,海量数据 处理方法总结
- wcf学习--建立最简单的WCF服务
- AutoCompleteTextView的使用
- bloom filter
- 伸长的守候
- maven configuration
- 从串口驱动的移植看linux2.6内核中的驱动模型 platform device & platform driver
- JS 光标应用