随笔分类 -  2012-1000系列

上一页 1 2 3 4 5 6 7 8 ··· 13 下一页

 
HDU 1124 Factorial
摘要: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 阅读(122) 评论(0) 推荐(0)
HDU 3279 Nth Largest Value
摘要: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 阅读(191) 评论(0) 推荐(0)
HDU 2304 Electrical Outlets
摘要: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 阅读(207) 评论(0) 推荐(0)
HDU 2715 Herd Sums
摘要: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 阅读(213) 评论(0) 推荐(0)
HDU 2716 Message Decowding
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2716水题View Code #include <iostream>using namespace std ;int main(){ char key[27],mes[81] ; while(~scanf("%s%*c",key)) { gets(mes) ; for(int i=0;mes[i];i++) { if(mes[i]>='A'&&mes[i]<='Z') putchar(key[mes... 阅读全文
posted @ 2012-05-31 11:22 LegendaryAC 阅读(153) 评论(0) 推荐(0)
HDU 2648 Shopping
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2648stl的map直接建立映射View Code #include <iostream>#include <algorithm>#include <string>#include <map>using namespace std ;string name[10001];int main(){ int n; while(~scanf("%d",&n)) { for(int i=0;i<n;i++) cin >> na 阅读全文
posted @ 2012-05-31 00:38 LegendaryAC 阅读(361) 评论(0) 推荐(0)
HDU 3336 Count the string
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3336求字符串的前缀在字符串中一共出现多少次。这个讲解的很清楚,传送门:http://972169909-qq-com.iteye.com/blog/1114968我用的思想是递推,把next数组向右平移一位,转移... 阅读全文
posted @ 2012-05-30 23:27 LegendaryAC 阅读(180) 评论(0) 推荐(0)
HDU 2800 Adding Edges
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2800View Code #include <iostream> using namespace std; int main(){ int n; while(scanf("%d",&n),n) printf("%d\n",(n+1)>>1); return 0;} 阅读全文
posted @ 2012-05-30 18:05 LegendaryAC 阅读(152) 评论(0) 推荐(0)
HDU 2594 Simpsons’ Hidden Talents
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2594好题,做完之后直接对KMP的理解提升一个档次。主要考察对_next数组含义的理解,之前的理解有点模糊,卡了两个半小时。View Code #include #include #include #include... 阅读全文
posted @ 2012-05-30 17:50 LegendaryAC 阅读(200) 评论(0) 推荐(0)
HDU 1686 Oulipo
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1686求子串个数,可重复,直接上KMP模板View Code #include #include using namespace std ; int n,m;char a[1000002],b[10002];int... 阅读全文
posted @ 2012-05-30 14:22 LegendaryAC 阅读(158) 评论(0) 推荐(0)
HDU 1711 Number Sequence
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1711终于炼化了kmp算法,就算是现在我仍然惊异于字符串匹配居然存在线性时间的算法这种超出了我这种sb认知的东西。自己搞了N久,发现还是没有网上的模板写的好,这里直接收藏了。View Code #include #... 阅读全文
posted @ 2012-05-30 13:45 LegendaryAC 阅读(176) 评论(0) 推荐(0)
SRM 544 DIV 2 250
摘要:坑点:0特判View Code const double esp=1e-11;string ElectionFraudDiv2::IsFraudulent(vector <int> percentages) { vector <double> sb ; double sum=0; for (int i = 0 ; i < percentages.size() ; i++) { sum+=percentages[i]+0.0; sb.push_back(percentages[i]+0.0); } double sum1,sum2;... 阅读全文
posted @ 2012-05-29 23:56 LegendaryAC 阅读(186) 评论(0) 推荐(0)
HDU 1677 Nested Dolls
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1677这道题纠结了N个小时,因为原来找的模板里少了两个等号。。。结果就是错在了我一直觉得不会错的LIS里,让我认清了上升和非降的区别?下降数列的个数等于LIS,和导弹拦截那道题基本一致ps:连着三道LIS看排名都进了前三,好开心~View Code #include <iostream>#include <algorithm>using namespace std ;int dp[10001],p[20001];typedef struct L{ int w,h;}L;L kk[200 阅读全文
posted @ 2012-05-29 12:07 LegendaryAC 阅读(464) 评论(0) 推荐(0)
HDU 1950 Bridging signals
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1950和上一题基本一样,二分dp求LISps:排名居然刷到第一了,原来从来没有遇到呢,好开心~View Code #include <iostream>using namespace std ;int dp[10001],p[40001];int LIS(int n){ int l,r,m,i,tail = 0; for ( dp[ ++ tail ] = p[ 1 ],i = 2 ; i <= n ; ++ i ) { if ( dp[ tail ] <= p[ i ] )... 阅读全文
posted @ 2012-05-28 21:37 LegendaryAC 阅读(198) 评论(0) 推荐(0)
HDU 1025 Constructing Roads In JGShining's Kingdom
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1025题目有一定迷惑性,实际就是求LIS,我原来掌握的朴实的O(n^2)算法果断超时,新学了一种二分dp O(nlog(n))的算法,直接上模板了,还要多多体会啊View Code #include <iostream>using namespace std ;int dp[10001],p[50001];int LIS(int n){ int l,r,m,i,tail = 0; for ( dp[ ++ tail ] = p[ 1 ],i = 2 ; i <= n ; ++ i ) { . 阅读全文
posted @ 2012-05-28 21:29 LegendaryAC 阅读(124) 评论(0) 推荐(0)
HDU 1316 How Many Fibs?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1316大数,斐波那契数列View Code import java.io.*;import java.math.*;import java.util.*;import java.text.*;public class Main{ public static void main(String[]args) { Scanner cin=new Scanner (new BufferedInputStream(System.in)); BigInteger a,b; ... 阅读全文
posted @ 2012-05-28 15:45 LegendaryAC 阅读(185) 评论(0) 推荐(0)
HDU 1394 Minimum Inversion Number
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1394求最小逆序数,逆序数的树状数组求法昨天学会了,今天这题开始用个无脑O(n*n*log(n))的方法,果断超时。其实逆序数只用求一边,每移动一次数列,逆序数增加num[i]-1个,对应减少n-num[i]个,递推即可。View Code #include <stdio.h>#include <stdlib.h> #include <string.h>int n;int tree[5001],num[5001];int lowbit(int i){ return i&am 阅读全文
posted @ 2012-05-28 15:00 LegendaryAC 阅读(163) 评论(0) 推荐(0)
HDU 1016 Prime Ring Problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1016经典问题,素数环。直接回溯即可。View Code #include <stdio.h>#include <string.h>int n;int a[30];int prime[100],vis[30];void dfs(int cur){ if(cur==n && prime[a[0]+a[n-1]]==0) { printf("%d",a[0]); for(int i=1;i<n;i++) printf(" %d" 阅读全文
posted @ 2012-05-28 12:37 LegendaryAC 阅读(169) 评论(0) 推荐(0)
HDU 2689 Sort it
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2689树状数组求逆序数,原来一直没搞明白,今天看了一遍文章讲的很清楚,下面把有关内容粘过来:对于小数据,可以直接插入树状数组,对于大数据,则需要离散化,所谓离散化,就是将100 200 300 400 500 ---> 1 2 3 4 5这里主要利用树状数组解决计数问题。首先按顺序把序列a[i]每个数插入到树状数组中,插入的内容是1,表示放了一个数到树状数组中。然后使用sum操作获取当前比a[i]小的数,那么当前i - sum则表示当前比a[i]大的数,如此反复直到所有数都统计完,比如4 3 1 2 i 阅读全文
posted @ 2012-05-28 01:24 LegendaryAC 阅读(479) 评论(0) 推荐(0)
HDU 2154 跳舞毯
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2154无聊题。。。View Code #include <stdio.h>#include <stdlib.h> #include <string.h>const int mod=10000;int a[1001],b[1001],c[1001];int main(){ int n; while(scanf("%d",&n),n) { a[0]=1;b[0]=c[0]=0; for(int i=1;i<=n;i++) { a[i... 阅读全文
posted @ 2012-05-28 00:50 LegendaryAC 阅读(252) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 ··· 13 下一页