sgu111-112大数运算
2014-05-09 16:10
267 查看
111原题链接http://acm.sgu.ru/problem.php?contest=0&problem=111
112原题链接http://acm.sgu.ru/problem.php?contest=0&problem=112
这里我超级偷懒,用了 J***A的大数类~~~
sgu111,二分查找
sgu112
112原题链接http://acm.sgu.ru/problem.php?contest=0&problem=112
这里我超级偷懒,用了 J***A的大数类~~~
sgu111,二分查找
import java.io.*; import java.math.*; import java.util.*; public class Solution { public static void main(String[] args) { BigInteger l = new BigInteger("1"); BigInteger r = (new BigInteger("10")).pow(500); BigInteger one = new BigInteger("1"); Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigInteger x = cin.nextBigInteger(); BigInteger mid,ans; ans = new BigInteger("1"); while(true){ mid = (l.add(r)).shiftRight(1); if( (mid.pow(2)).compareTo(x) > 0){ r = mid.subtract(one); }else{ ans = mid; l = mid.add(one); } if(l.compareTo(r) > 0) break; } System.out.println(ans); } }
sgu112
import java.io.*; import java.math.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int x = cin.nextInt(); int y = cin.nextInt(); BigInteger bigx = BigInteger.valueOf(x); BigInteger bigy = BigInteger.valueOf(y); BigInteger result = bigx.pow(y).subtract(bigy.pow(x)); System.out.println(result); } }
相关文章推荐
- (高精度运算4.7.29)SGU 112 a^b - b^a(大数的幂运算)
- SGU 111 大数开根号
- sgu-112(java 大数)
- sgu 112 a^b - b^a java大数
- Very simple problem - SGU 111(大数开方)
- sgu-111-111. Very simple problem(java大数)
- SGU111 大数开方 Evolution
- SGU - 112 - ab-ba (大数高精度)
- SGU111 Very simple problem(大数开方)
- 【片段集】大数运算
- 大数的四则运算
- JAVA大数运算
- 汇编编写程序实现大数运算
- 有关大数的运算(2)
- 大数的运算思想
- 大数运算之加减乘法
- 大数字符串的四则运算之加法----Java代码实现
- 两个大数相加比较符合自然运算的算法
- c语言面试题之大数运算
- 【C++】C++大数的运算