摘要: DescriptionMr. Tenant is going to buy a new house. In fact, he is going to buy a piece of land and build his new house on it. In order to decide which... 阅读全文
posted @ 2015-08-04 20:14 茶飘香~ 阅读(246) 评论(0) 推荐(0) 编辑
摘要: Every year there is the same problem at Halloween: Each neighbour is only willing to give a certaintotal number of sweets on that day, no matter how m... 阅读全文
posted @ 2015-08-04 16:32 茶飘香~ 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 输入n(using namespace std;typedef long long LL;LL a[15];LL gcd(LL a,LL b) //求a和b的最大公约数{ if(b) return gcd(b,a%b); return a;}LL lcm(LL a,LL b) //求a和b的最小公倍... 阅读全文
posted @ 2015-08-03 15:57 茶飘香~ 阅读(417) 评论(0) 推荐(0) 编辑
摘要: typedef long long LL;LL quick(LL a,LL b,LL m) //a^b%m 快速取模 使得复杂度从0(b){ // 降低为0(log2(b)) LL ans=1; while(b) { if(b&1) ans=ans*a%m; b>>=1; a=a*a%m; } re... 阅读全文
posted @ 2015-08-03 10:48 茶飘香~ 阅读(1015) 评论(0) 推荐(0) 编辑
摘要: 输入N和M,M表示接下来会输入M个数,求从1到N中不能被这M个数整出的数的个数。思路:先算出从1到N中能被这M个数整除(即是这M个数中任意一个数的倍数)的数的个数,在用N减去就是答案了。#include #include using namespace std;long long num[20];l... 阅读全文
posted @ 2015-08-02 17:37 茶飘香~ 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题意:将A(n , m)转化成k进制后末尾0的个数。分析:求A(n, m)转化成k进制以后末尾0的个数。对k素因子分解,第i个因子为fac[i],第i个因子的指数为num[i],然后再对n的对A(n, m)进行素因子分解,设count[i]代表fac[i]对应的指数,ans = min{count[... 阅读全文
posted @ 2015-08-01 19:51 茶飘香~ 阅读(1233) 评论(0) 推荐(0) 编辑
摘要: 计算组合数C(m,n) 即从m个总体中取出n个的取法总数。一、直接用公式C(m,n)=m!/((m-n)!*n!) 或 C(m,n)=m*(m-1)*……*(m-n+1)/n!此方法只能计算较小的组合数代码实现:#include using namespace std;int main(){ in... 阅读全文
posted @ 2015-06-08 18:59 茶飘香~ 阅读(469) 评论(0) 推荐(0) 编辑
摘要: 两条平面直线是否相交(直线长度大于0,可以重叠)直线为(x1,y1),(x2,y2)和(x3,y3),(x4,y4)#include using namespace std;int cj(int a1,int a2,int b1,int b2,int c1,int c2){ return (c1-... 阅读全文
posted @ 2015-06-06 13:53 茶飘香~ 阅读(918) 评论(0) 推荐(0) 编辑
摘要: description给定一个括号字符数组S,S可以用两个整数数组P和W来描述,其中:数组P中的元素Pi定义为:第i个右括号前面有Pi个左括号;数组W中的元素Wi定义为,第i个右括号和其配对的左括号之间所包含的完整的括号的对数。现在给你P数组,让你求出该字符数组S所对应的W数组。比如下面这个例子 ... 阅读全文
posted @ 2015-05-22 16:41 茶飘香~ 阅读(307) 评论(0) 推荐(0) 编辑
摘要: cc-test08-1链表的输入与输出Problem : 1049Time Limit : 1000msMemory Limit : 65536Kdescription 读入学生的信息:学号(8位整数)、姓名(20个字符)、性别(1个字符)3门课的成绩(2位小数)。计算每个学生的平均成绩(2位小数)... 阅读全文
posted @ 2015-05-07 21:58 茶飘香~ 阅读(271) 评论(0) 推荐(0) 编辑