LeeBlog

导航

2011年5月10日 #

HDU 2181 哈密顿绕行世界问题

摘要: 这个就是一深搜,不解释,还有,测试数据太弱了。#include<stdio.h>#include<string.h>int map[23][4],des[23],num[23],f,n;void DFS( int p,int nu ){ if( nu == 20 && ( map[p][1] == n || map[p][2] == n || map[p][3] == n ) ) { printf( "%d: ",++f ); for( int i = 0; i < 20; ++i ) printf( "%d &quo 阅读全文

posted @ 2011-05-10 23:23 LeeBlog 阅读(553) 评论(0) 推荐(0) 编辑

HDU 2553 N皇后问题

摘要: 这题跟其实是以DFS经典题,如果按一般思路一行一行来选,那样会灰常暴力,但是仔细思考可得这题可简化思路,因为没行只能放一个,所以只要搜索N个就行了。。。。。 而对于每一个只要判断跟前面是否有冲突就行了( DP 思想,分步来 )。#include<stdio.h>#include<string.h>int n,map[20],des[20],cnt,num[11];void DFS( int num ){ if( num == n + 1 ) { ++cnt; return ; } for( int i = 1; i <= n; ++i ) { if( !des[i 阅读全文

posted @ 2011-05-10 19:18 LeeBlog 阅读(231) 评论(0) 推荐(1) 编辑

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 阅读(222) 评论(0) 推荐(0) 编辑

POJ PKU 2305 java大数进制转化 JAVA 大数转换成字符串 转

摘要: 题目描述:给你两个n进制数a和b。以n进制的形式输出a % b。解题报告:String st = Integer.toString(num, base); // 把num当做10进制的数转成base进制的st(base <= 35).int num = Integer.parseInt(st, base); // 把st当做base进制,转成10进制的int(parseInt有两个参数,第一个为要转的字符串,第二个为说明是什么进制).BigInter m = new BigInteger(st, base); // st是字符串,base是st的进制.1.如果要将一个大数以2进制形式读入 阅读全文

posted @ 2011-05-10 10:15 LeeBlog 阅读(319) 评论(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 阅读(190) 评论(0) 推荐(0) 编辑