【PKU1001】Exponentiation(高精度乘法)
Time Limit: 500MS | Memory Limit: 10000K | |
Total Submissions: 145642 | Accepted: 35529 |
Description
This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.
Input
Output
Sample Input
95.123 12
0.4321 20
5.1234 15
6.7592 9
98.999 10
1.0100 12
Sample Output
548815620517731830194541.899025343415715973535967221869852721
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
43992025569.928573701266488041146654993318703707511666295476720493953024
29448126.764121021618164430206909037173276672
90429072743629540498.107596019456651774561044010001
1.126825030131969720661201
高精度乘法 问了下晖哥ICPC比赛时可以用多种语言混合提交 这里就给出Java的写法 建议掌握Java的大数类
C++的版本自己感兴趣的自己去敲一敲好了 把小数点去掉乘法最后加上小数点就好了
import java.math.BigDecimal;
import java.util.Scanner; public class Main {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
BigDecimal bd = new BigDecimal(sc.next());
BigDecimal result = bd.pow(sc.nextInt());
String s = result.stripTrailingZeros().toPlainString();
if (s.startsWith("0"))
s = s.substring(1);
System.out.println(s);
}
}
}
【PKU1001】Exponentiation(高精度乘法)的更多相关文章
- 【POJ 1001】Exponentiation (高精度乘法+快速幂)
BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...
- [vijos P1040] 高精度乘法
如果这次noip没考好,完全是因为从7月29日之后就没有再写过程序了.说起来,真是一个泪流满面的事实… 那这样一个弱智题练手恢复代码能力,竟然还花了我两个晚上(当然不是两整个晚上…) 第一天TLE了, ...
- hdu 1042 N!(高精度乘法 + 缩进)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目大意:求n!, n 的上限是10000. 解题思路:高精度乘法 , 因为数据量比较大, 所以 ...
- hdu 1042 N!(高精度乘法)
Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in ...
- 1001. Exponentiation高精度运算总结
解题思路 这道题属于高精度乘法运算,要求输入一个实数R一个指数N,求实数R的N次方,由于R有5个数位,而N又特别大,因此用C++自带的数据类型放不下. 解题思路是通过数组储存每次乘积结果和底数的每一位 ...
- Vijos 1040 高精度乘法
描述 高精度乘法 输入:两行,每行表示一个非负整数(不超过10000位) 输出:两数的乘积. 样例1 样例输入1 99 101 样例输出1 9999 题解 这道题和之前的Vijos 1010 清帝之惑 ...
- [leetcode]43. Multiply Strings高精度乘法
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and ...
- H. GSS and Simple Math Problem 高精度乘法模板
链接:https://www.nowcoder.com/acm/contest/104/G来源:牛客网 题目描述 Given n positive integers , your task is to ...
- 高精度乘法--C++
高精度乘法--C++ 模仿竖式乘法,在第一步计算的时候将进位保留,第一步计算完再处理进位.(见代码注释) 若要处理正负情况,可在数据输入后加以判断,处理比较简单. 小数计算也可参照该方法,不过对齐方式 ...
随机推荐
- Onedrive 明年初基础容量缩小到5G,执行这一步骤避免(保持30G)
Onedrive作为微软的云盘,相当实用,存储一些照片文档. 之前微软一直执行免费用户可以永久拥有30G空间(基础+开启功能获得). 但微软打算从明年开始减低这一优惠至5G. 不过最近微软有一些放松, ...
- DOM位置参数
以chrome浏览器测试为准 scrollwidth scrollheight clientwidth clientheight offsetwidth offsetheight 对象的实际宽高 包括 ...
- GeoHash原理解析
GeoHash 核心原理解析 引子 一提到索引,大家脑子里马上浮现出B树索引,因为大量的数据库(如MySQL.oracle.PostgreSQL等)都在使用B树.B树索引本质上是对索引字段 ...
- Axis2测试webservice server以及client
一.环境搭建 下载axis2-1.6.2-war.zip/axis2-1.6.2-bin.zip等. 参考axis2-1.6.2-war\README.txt以及axis2-1.6.2-war\axi ...
- 解决ThinkPHP关闭调试模式时报错的问题汇总
解决ThinkPHP关闭调试模式时报错的问题汇总 案例一: 最近用ThinkPHP开发一个项目,本地开发测试完成上传到服务器后,第一次打开正常,再刷新页面时就出现 "页面调试错误,无法找开页 ...
- foreach循环 Java
第一次遇到foreach循环,是在PHP的数组中,同样,在Java数组中,也遇到了foreach循环,都是用来遍历数组(集合).遍历数组,首先想到的一般都是用while,do while,for循环, ...
- 主要由顶点容器构成的平面图形类(Shape)——(第一次作业Draw类定义升级)
// https://github.com/orocos/orocos_kinematics_dynamics/blob/master/orocos_kdl/src/frames.hpp // Vec ...
- C#联机获取公网IP
C#获取IP的方式有很多种,这里通过http://www.ipip.net/这个稳定的在线IP库的来获取公网IP. string tempip = "0.0.0.0"; WebRe ...
- 关于Blender
一.插入背景图片 1.'N'调出右栏工具,拖至后面有Background Images 打钩,点开三角形,按'add image'all views 可以确定加入图片到哪个view,open可以添加 ...
- 继续向peersim的event-driven模式开火!(新手勿喷)
昨天学习了peersim的cycle模式,今天开始继续悟事件模式. 总的来说,我个人认为事件模式是周期模式的升级版,或者说,周期模式只是事件模式的一个子功能. 事件模式是基于时间和事件的(没打错),每 ...