2013年6月17日

hdoj 2157 How many ways??

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2157解题思路:矩阵快速幂 1 #include 2 using namespace std; 3 4 int n; //n个点,对应nxn矩阵 5 6 struct Matrix{ 7 int a[20][20]; 8 }res; 9 10 Matrix multiply(Matrix x,Matrix y){11 Matrix temp;12 for(int i=0;i>=1;26 origin=multiply(origin,origin);27 ... 阅读全文

posted @ 2013-06-17 23:23 SCNU20102200088 阅读(242) 评论(0) 推荐(0) 编辑

2013年6月15日

Java在ACM中的应用

摘要: 一、输入(主要是使用Scanner类)1、导入Scanner类:import java.util.Scanner;2、创建Scanner类的对象:Scanner cin=new Scanner(System.in);3、使用Scanner类的对象读入各种类型的数据:①读入数据(常用)读一个整数:int n=cin.nextInt(); 【C:scanf("%d",&n); 】 【C++:cin>>n;】读一个字符串:String s=cin.next(); 【C:scanf("%s",s); 】 【C++:cin>>s; 阅读全文

posted @ 2013-06-15 21:50 SCNU20102200088 阅读(165) 评论(0) 推荐(0) 编辑

2013年6月14日

zoj 1406 Jungle Roads

摘要: 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=406解题思路:最小生成树(kruskal 算法 + 优先队列 + 并查集) 1 /************************************************************************** 2 user_id: SCNU20102200088 3 problem_id: zoj 1406 4 problem_name: Jungle Roads 5 *********************************... 阅读全文

posted @ 2013-06-14 13:43 SCNU20102200088 阅读(146) 评论(0) 推荐(0) 编辑

Java大数

摘要: java.math包中的BigInteger类和BigDecimal类分别提供任意精度的整数和小数运算。1、BigInteger类①导入:import java.math.BigInteger;②常用方法:BigInteger valueOf(long val) 【转换】int compareTo(BigInteger val) 【返回值1、0、-1分别表示大于、等于、小于】BigInteger add(BigInteger augend) 【加法】BigInteger subtract(BigInteger subtrahend) 【减法】BigInteger multiply(BigInt 阅读全文

posted @ 2013-06-14 02:18 SCNU20102200088 阅读(354) 评论(0) 推荐(0) 编辑

2013年6月2日

hdoj 1009 FatMouse' Trade

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1009解题思路:按单位 cat food 所能换取的 JavaBeans 量(即 J[i]/F[i] )从大到小排序,优先选择比值大的进行交换,直到消耗完 cat food 。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 struct Trade{ 7 int J,F; 8 double C; 9 bool operator t.C;11 }12 }T[1005];13 14 int mai... 阅读全文

posted @ 2013-06-02 14:08 SCNU20102200088 阅读(157) 评论(0) 推荐(0) 编辑

导航