uva 748 Exponentiation

import java.util.Scanner;
import java.math.BigDecimal;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		BigDecimal a;
		int n;
		while(in.hasNext()){
			a = in.nextBigDecimal();
			n = in.nextInt();
			String s = a.pow(n).stripTrailingZeros().toPlainString();
			if(s.startsWith("0"))
				s = s.substring(1);
			System.out.println(s);
		}
	}
}
时间: 2024-10-15 00:07:33

uva 748 Exponentiation的相关文章

Exponentiation UVA 748

//算法:获得无小数点的输入串,然后对该串进行普通的高精度乘法运算 //运算得到结果后,添加小数点,最后除去串头和串尾的0即可 #include <stdio.h> #define MAXN 200 char R[10]; char E[6];//寄存无小数点的输入串 char temp[MAXN]; char ans[MAXN];//寄存答案串 int n,left; void multip(); int main(){ int i,j,k; int cnt; // freopen(&quo

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

高精度题目列表

JAVA大数类练手 748 - Exponentiation Uva 424 Uva 10106 Uva 465 Uva 10494 POJ 2389 POJ 2756 HDU 1715 HDU 1047 HDU 1297 HDU 1002 HDU 1316 HDU 1865 HDU 1250 HDU 1042 HDU 1753 POJ 1220 HDU 2100 Uva 10023 Uva 10069 HDU 4762 Uva 10497 Uva 10844 HDU 4873 Uva 1478

uva 1103

#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <cstdlib> #include <stack> #include <cctype> #include <string> #include <malloc.h> #include

UVA - 10298 Power Strings (KMP求字符串循环节)

Description Problem D: Power Strings Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiati

uva748 - Exponentiation

import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class Exponentiation { public static void main(String[] args){ Scanner sc = new Scanner(new BufferedInputStream(System.in)); BigDecimal bd1, ans; DecimalFormat df =

UVA - 12532 Interval Product

http://acm.bnu.edu.cn/v3/problem_show.php?pid=27853 Interval Product Time Limit: 2000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID: 1253264-bit integer IO format: %lld Java class name: Main Prev Submit Status Statistics Di

UVA - 11384 - Help is needed for Dexter (找规律!!)

UVA - 11384 Help is needed for Dexter Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Submit Status Description Problem H Help is needed for Dexter Time Limit: 3 Second Dexter is tired of Dee Dee. So he decided to keep Dee Dee b

UVA 10110 Light, more light【经典开灯问题】

Light, more light Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID: 10110 64-bit integer IO format: %lld      Java class name: Main Prev Submit Status Statistics Discuss Next Type: None None Graph Theory