LeeBlog

导航

随笔分类 -  大数

HDU 1063 Exponentiation
摘要:JAVA 水过import java.io.*;import java.util.*;import java.math.*;public class aa{ public static void main( String[] args ) { BigDecimal a,b; int c; Scanner cin = new Scanner(System.in); while( cin.hasNext() ) { a = cin.nextBigDecimal(); b = BigDecimal.valueOf(1); c = cin.nextInt(); for( int i = 0; i &l 阅读全文

posted @ 2011-05-10 11:10 LeeBlog 阅读(226) 评论(0) 推荐(0)

HDU 1715 大菲波数
摘要:JAVA水过import java.io.*;import java.util.*;import java.math.*;public class aa{ public static void main( String[] args ) { BigInteger f[] = new BigInteger[1005]; f[1] = BigInteger.valueOf(1); f[2] = BigInteger.valueOf(1); for( int i = 3; i < 1005; ++i ) f[i] = f[i-1].add(f[i-2]); Scanner cin = new 阅读全文

posted @ 2011-05-10 09:55 LeeBlog 阅读(197) 评论(0) 推荐(0)

大明 A + B JAVA
摘要:java 水过import java.io.*;import java.util.*;import java.math.BigDecimal;public class aa{ public static void main( String args[] ) { BigDecimal a,b; Scanner in = new Scanner ( System.in ); //int t = in.nextInt(); while( in.hasNext() ) { a = in.nextBigDecimal();b = in.nextBigDecimal(); BigDecimal c = a 阅读全文

posted @ 2011-05-09 21:33 LeeBlog 阅读(212) 评论(0) 推荐(0)

HDU 2100 Lovekey
摘要:这是一大数题,直接套模板,其实跟十进制差不多,不过把对10取余改成对26取余就行了,水过#include<stdio.h>#include<string.h>#define max 250int num[max];char str1[max],str2[max];void cal( ){ memset( num,0,sizeof( num ) ); int len1 = strlen( str1 ),len2 = strlen( str2 ); for( int i = 0; i < ( len1 > len2 ? len1 : len2 ); ++i )/ 阅读全文

posted @ 2011-04-09 17:51 LeeBlog 阅读(249) 评论(0) 推荐(0)

HDU 2054 A == B ?
摘要:JAVAimport java.io.*;import java.util.*;import java.math.*;import java.io.BufferedInputStream; public class aa{ public static void main( String[] args ) { BigDecimal a,b; Scanner cin = new Scanner(System.in); while( cin.hasNext() ) { a = cin.nextBigDecimal(); b = cin.nextBigDecimal(); a = a.stripTra 阅读全文

posted @ 2011-04-09 13:47 LeeBlog 阅读(749) 评论(0) 推荐(0)

HDU 1402 A * B Problem Plus
摘要:这是大数相乘的一模板题;先把两个字符串变成ASCII码(不能和倒置放在一块,否则会出错),然后把他们全部倒置,然后再将他们相乘,最后再进位,不过这样会超时,将会在近段时间内发布不超时的代码#include<stdio.h>#include<string.h>#include<stdlib.h>#define Max 100000int num[Max];char str1[Max] = {0},str2[Max] = {0};void cal( ){ int len1 = strlen( str1 ),len2 = strlen( str2 ); for( 阅读全文

posted @ 2011-04-09 10:30 LeeBlog 阅读(388) 评论(0) 推荐(0)

HDU 1316 How Many Fibs? 大数
摘要:Javaimport java.io.*;import java.util.*;import java.math.*;public class aa{ public static void main( String[] args ) { BigInteger f[] = new BigInteger[505],a,b; f[1] = BigInteger.valueOf(1); f[2] = BigInteger.valueOf(2); for( int i = 3; i < 505; ++i ) f[i] = f[i-1].add( f[i-2] ); Scanner cin = ne 阅读全文

posted @ 2011-04-08 21:21 LeeBlog 阅读(344) 评论(0) 推荐(0)

HDU 1047 Integer Inquiry
摘要:JAVA水过import java.io.*;import java.util.*;import java.math.*;public class aa{ public static void main( String[]args ) { Scanner cin=new Scanner(System.in); int t; cin.hasNextInt(); t = cin.nextInt(); for( int i = 1; i <= t; ++i ) { BigInteger a,b,c; c = BigInteger.valueOf(0); b = c; while( cin.ha 阅读全文

posted @ 2011-03-29 20:15 LeeBlog 阅读(212) 评论(0) 推荐(0)

HDU 1042 N!
摘要:JAVAimport java.io.*;import java.util.*;import java.math.BigInteger;import java.math.BigDecimal;;public class aa{ public static void main( String args[] ) { int a; Scanner in = new Scanner ( System.in ); //int t = in.nextInt(); while( in.hasNext() ) { a = in.nextInt(); BigInteger res = BigInteger.ON 阅读全文

posted @ 2011-03-29 17:26 LeeBlog 阅读(255) 评论(0) 推荐(1)

HDU 1002 A + B Problem II 大数相加
摘要:java 水过import java.io.*;import java.util.*;import java.math.BigInteger;public class aa{ public static void main( String args[] ) { BigInteger a,b; Scanner in = new Scanner ( System.in ); int t = in.nextInt(); for( int i = 1; i <= t; ++i ) { in.hasNext(); a = in.nextBigInteger();b = in.nextBigInte 阅读全文

posted @ 2011-03-29 15:51 LeeBlog 阅读(902) 评论(1) 推荐(0)