zoj 2818 Root of the Problem(数学思维题)
题目链接:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818
题目描述:
Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be less than, equal to, or greater than B.
Input: The input consists of one or more pairs of values for B and N. Each pair appears on a single line, delimited by a single space. A line specifying the value zero for both B and N marks the end of the input. The value of B will be in the range 1 to 1,000,000 (inclusive), and the value of N will be in the range 1 to 9 (inclusive).
Output: For each pair B and N in the input, output A as defined above on a line by itself.
4 3
5 3
27 3
750 5
1000 5
2000 5
3000 5
1000000 5
0 0
1
2
3
4
4
4
5
16
/*问题 输入正整数b和n,找到一个正整数a满足a^n最靠近b
解题思路 a^n=b,那么a等于b的算数n次方根,即b的1/n次方等于a, 比较a^n和(a+1)^n谁更接近b */
#include<cstdio>
#include<cmath>
int main()
{
double b,n;
int a;
while(scanf("%lf%lf",&b,&n),b+n != )
{
a=(int)pow(b,/n);//强制类型转换时直接截取整数部分
if(b-pow(a,n) < pow(a+,n)-b)
printf("%d\n",a);
else
printf("%d\n",a+);
}
return ;
}
zoj 2818 Root of the Problem(数学思维题)的更多相关文章
- zoj 2818 Root of the Problem
Root of the Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Given positive integers B and ...
- PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记
PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...
- UVa10025 The ? 1 ? 2 ? ... ? n = k problem 数学思维+规律
UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operator ...
- POJ 3100 & ZOJ 2818 & HDU 2740 Root of the Problem(数学)
题目链接: POJ:id=3100" style="font-size:18px">http://poj.org/problem? id=3100 ZOJ:http ...
- ZOJ Saddle Point 数学思维题
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5564 根据它的定义是行最小,列最大. 可以证明鞍点是唯一的. ...
- EOJ2018.10 月赛(B 数学+思维题)
传送门:Problem B https://www.cnblogs.com/violet-acmer/p/9739115.html 题意: 找到最小的包含子序列a的序列s,并且序列s是 p -莫干山序 ...
- EOJ2018.10 月赛(A 数学+思维题)
传送门:Problem A https://www.cnblogs.com/violet-acmer/p/9739115.html 题意: 能否通过横着排或竖着排将 1x p 的小姐姐填满 n x m ...
- HDU5742 It's All In The Mind 数学思维题
Problem Description Professor Zhang has a number sequence a1,a2,...,an. However, the sequence is not ...
- 【数学 思维题】HDU4473Exam
过程很美妙啊 Problem Description Rikka is a high school girl suffering seriously from Chūnibyō (the age of ...
随机推荐
- bootstrap3相关文档
,每列分配多列 <divclass="container"> <div class="row"> <div class=" ...
- 必修3第三章概率mindmaps
% !Mode:: "TeX:UTF-8" \documentclass{article} \usepackage[screen]{geometry} \usepackage[no ...
- Delphi 的多线程使用已经很简单了
先看一个非多线程的例子, 代码执行时不能进行其它操作(譬如拖动窗体): {自定义方法: 在窗体上绘制...} procedure MyMethod; var i: Integer; begin ...
- php+sqlserver之如何操作sqlserver数据库
https://blog.csdn.net/xia13100004562/article/details/58598872 2016年12月19日 17:15:39 阅读数:6790 前面已经基本配置 ...
- [Leet code 2]Two Sum
1 题目 You are given two linked lists representing two non-negative numbers. The digits are stored in ...
- Windows核心编程:第4章 进程
Github https://github.com/gongluck/Windows-Core-Program.git //第4章 进程.cpp: 定义应用程序的入口点. // #include &q ...
- 验证FluentValidation
FluentValidation https://www.xcode.me/code/fluentvalidation-dot-net-library 这里写得很详细了
- UWP Button添加圆角阴影(三)
原文:UWP Button添加圆角阴影(三) Composition DropShadow是CompositionAPI中的东西,使用Storyboard设置某个属性,就是频繁的触发put_xxx() ...
- Python 爬虫(二十五) Cookie的处理--cookielib库的使用
Python中cookielib库(python3中为http.cookiejar)为存储和管理cookie提供客户端支持. 该模块主要功能是提供可存储cookie的对象.使用此模块捕获cookie并 ...
- PHP eval函数
代码: eval("echo'hello world';"); 上边代码等同于下边的代码: echo"hello world"; 在浏览器中都输出:hello ...