Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:51
Show Gist options
  • Save pinglunliao/8b5b7787db2640d86dd9 to your computer and use it in GitHub Desktop.
Save pinglunliao/8b5b7787db2640d86dd9 to your computer and use it in GitHub Desktop.
b115: TOI2008 2. 大數運算 FYI: https://yunlinsong.blogspot.com/2015/10/toi2008-2.html
import java.util.Scanner;
import java.math.BigInteger;
public class JAVA {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String op;
BigInteger a, b, c = null;
while (cin.hasNext()) {
a = cin.nextBigInteger();
op = cin.next();
b = cin.nextBigInteger();
if(op.equals("+") == true)
{
c = a.add(b);
}
else if(op.equals("-") == true)
{
c = a.subtract(b);
}
else if(op.equals("*") == true)
{
c = a.multiply(b);
}
else if(op.equals("/") == true)
{
c = a.divide(b);
}
System.out.println(c.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment