上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 47 下一页

2012年6月2日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1194跟着狗畅找了道水题做,他真无聊啊。。。View Code #include <iostream>using namespace std ;int main(){ int n,i; int s,d; scanf("%d",&n); while(n--) { scanf("%d%d",&s,&d); for(i=s;i>0;i--) if(abs(i*2-s)==d) { pr... 阅读全文
posted @ 2012-06-02 17:55 LegendaryAC 阅读(237) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2161素数判断,这题数据范围小的可怜,普通的筛法肯定没问题,不过为了练习我还是拿米勒拉宾测试写的。ps:为2b的自己流了一地泪View Code #include <iostream>using namespace std ;__int64 qpow(int a,int b,int r){ __int64 ans=1,buff=a; while(b) { if(b&1)ans=(ans*buff)%r; buff=(buff*buff)%r; b>>... 阅读全文
posted @ 2012-06-02 13:21 LegendaryAC 阅读(163) 评论(0) 推荐(0) 编辑

2012年6月1日

摘要: 直接献上模板View Code __int64 qpow(int a,int b,int r)//快速幂 { __int64 ans=1,buff=a; while(b) { if(b&1)ans=(ans*buff)%r; buff=(buff*buff)%r; b>>=1; } return ans;}bool Miller_Rabbin(int n,int a)//米勒拉宾素数测试 { int r=0,s=n-1,j; if(!(n%a)) return false; while(!(... 阅读全文
posted @ 2012-06-01 18:34 LegendaryAC 阅读(2546) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2138米勒拉宾素数测试,解大规模素数问题。View Code #include <iostream>using namespace std ;__int64 qpow(int a,int b,int r){ __int64 ans=1,buff=a; while(b) { if(b&1)ans=(ans*buff)%r; buff=(buff*buff)%r; b>>=1; } return ans;}bool Miller_Rabbin... 阅读全文
posted @ 2012-06-01 18:32 LegendaryAC 阅读(205) 评论(0) 推荐(0) 编辑

2012年5月31日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1563找只出现一次的数,排个序处理下就行View Code #include <iostream>#include <algorithm>using namespace std ;int main(){ int n; while(scanf("%d",&n),n) { int a[201]; a[1]=a[n+1]=-1; for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(... 阅读全文
posted @ 2012-05-31 23:51 LegendaryAC 阅读(195) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1124求n!末尾有多少个0,2*5出0,所以既求有多少个因子5View Code #include <iostream>using namespace std ;int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int ans=0; while(n) { n/=5; ans+=n; ... 阅读全文
posted @ 2012-05-31 16:05 LegendaryAC 阅读(114) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3279无聊题。。。View Code #include <iostream>#include <algorithm>using namespace std ;int main(){ int p; scanf("%d",&p); while(p--) { int cas; scanf("%d",&cas); int a[10]; for(int i=0;i<10;i++) scanf("%d",&a 阅读全文
posted @ 2012-05-31 13:07 LegendaryAC 阅读(184) 评论(0) 推荐(0) 编辑
 
摘要: 起床交3道水题HDOJ总算是到400题了。 从我接触程序设计到现在大概是七个月吧。七个月做这么一点题,简直是弱爆了,而且其中大部分是水题,做完能让我产生巨大成就感的题目不多。参加过几次为数不多的比赛,全部是以被虐爆收场。 明确下来“我要在大学好好搞ACM”这个目标也就是大一下学期的事情,之前可能对这个概念还很模糊吧,对刷题和学算法的热情不甚高涨,浪费了很多时间(大概能有两个多月无所事事?),不过既然决定了,那就向前看。转到计算机的专业是不太现实了,大学四年就在一个和计算机无关的专业混吧,毕竟每个人都有自己不同的活法。 比较神奇的事情是我在BISTU的oj上居然排到了第三,看来刷到第一... 阅读全文
posted @ 2012-05-31 13:00 LegendaryAC 阅读(153) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2304一个插头,n个插线板,问最后剩几个能插的电器的View Code #include <iostream>using namespace std ;int main(){ int n; scanf("%d",&n); while(n--) { int k; scanf("%d",&k); int s=0; for(int i=0;i<k;i++) { int w; sc... 阅读全文
posted @ 2012-05-31 12:39 LegendaryAC 阅读(194) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2715直接暴了。。。View Code #include <iostream>using namespace std ;int main(){ int n; while(~scanf("%d",&n)) { int ans=0,sum; for(int i=1;i<=n;i++) { sum=0; for(int j=i;j<=n;j++) { sum+=... 阅读全文
posted @ 2012-05-31 12:05 LegendaryAC 阅读(202) 评论(0) 推荐(0) 编辑
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 47 下一页