HDU 1753 (large -large -plus method)

2023-03-18  

Title: It is easy to understand

problem -solving ideas: For the topic of the basic operation of large numbers. When the output format is uncertain, we can try it:

1) Remove the tail invalid 0

2) Remove an integer part of less than 1

code is as follows:

package com.njupt.bigInteger;

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

public class HDU_1753_1 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		BigDecimal a,b,c;
		
		while(scanner.hasNext()){
			a = scanner.nextBigDecimal();
			b= scanner.nextBigDecimal();
			c = a.add(b);
			
			c = c.stripTrailingZeros();
			
			String str = c.toPlainString();
			
			if(str.startsWith("0.")){
				str = str.substring(1);
			}
			
			System.out.println(str);
			
		}
	}
}

source

Random Posts

docker container custom network bridge modify docker0 address

HDU -4403 -A very Hard Aoshu Proplem (DP + DFS + MAP + Multipmentual Principles)

WeChat Mini Program-the window background color is covered with page

D -Silver Cow Party Poj -3268 (DIJ -Figure Reverse) ID

Use tensorflow to perform machine learning instances (linear regression)