上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 21 下一页
摘要: http://poj.org/problem?id=3274***** 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int N=100001; 7 const int MOD=99991; 8 int Maxdis,k; 9 int c[N][32],sum[N][32];10 int vis[N][32];11 12 struct node13 {14 int row_i;15 struct node *next;16 }*hash[N];17 bool cmp(... 阅读全文
posted @ 2014-02-11 16:27 N_ll 阅读(165) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3007第一次用STL做的,TLE了,自己构造字符串哈希函数才可以。。TLE代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int main() 8 { 9 int n;10 scanf("%d",&n);11 while(n--)12 {13 int cnt = 0,j;14 char ss[120];15 string str,s,... 阅读全文
posted @ 2014-02-11 16:17 N_ll 阅读(169) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3468题意:就是区间的查询与更新。。#include #include const int maxn=100010;const int maxm=6600000;#define LL long longstruct node{ int a,b; int l,r; LL sum; LL h;} A[maxm];int Num[maxn],cnt;void build(int root){ int a = A[root].a; int b = A[root].b; int mid = (a+b)>>... 阅读全文
posted @ 2014-02-10 19:51 N_ll 阅读(129) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2892题意:输入n,m。n代表数轴的长度,m代表操作数。 D x: 摧毁点x Q x: 询问村庄x最左与最右没有被摧毁的点的距离R :恢复最后一个被摧毁的点 1 #include 2 #include 3 const int N=50001; 4 int c[N],keep[N],n; 5 bool vis[N]; 6 7 int lowbit(int x) 8 { 9 return x&(-x);10 }11 int sum(int x)12 {13 int res = 0;14 while(x > 0)15... 阅读全文
posted @ 2014-02-10 10:33 N_ll 阅读(304) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1286题意:求用3种颜色给n个珠子涂色的方案数。polya定理模板题。 1 #include 2 #include 3 4 long long gcd(long long a,long long b) 5 { 6 return b?gcd(b,a%b):a; 7 } 8 int main() 9 {10 long long n;11 while(~scanf("%lld",&n))12 {13 if (n==-1)14 break;15 if (n... 阅读全文
posted @ 2014-02-09 21:26 N_ll 阅读(223) 评论(0) 推荐(0)
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2316理解错一点题意就能WA到死。。。题中对于重复的单词,只输出一个,但是重复的单词个数要加上 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 const int N=100010;10 int vis[N];11 vectorv[N];12 mapmp;13 struct node1... 阅读全文
posted @ 2014-01-20 15:57 N_ll 阅读(265) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1276 1 #include 2 #include 3 const int N=1000020; 4 #define Max(a,b) (a)>(b)?(a):(b) 5 int dp[N],cash; 6 void ZeroOnePack(int cost)//01背包 7 { 8 for (int i = cash; i >= cost; i--) 9 {10 dp[i] = Max(dp[i],dp[i-cost]+cost);11 }12 }13 void ComplexPack(int ... 阅读全文
posted @ 2014-01-19 14:50 N_ll 阅读(175) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1836求两遍最长上升子序列,顺序求一遍,逆序求一遍。 1 #include 2 #include 3 const int N=1002; 4 int dp1[N],dp2[N]; 5 double a[N]; 6 int main() 7 { 8 int n; 9 scanf("%d",&n);10 for (int i = 1; i a[j])21 {22 if (temp 0; i--)30 {31 int temp = 0... 阅读全文
posted @ 2014-01-18 20:23 N_ll 阅读(150) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1080 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int INF=1<<28; 8 int score[220][220]; 9 void init()10 {11 score['A']['C']=score['C']['A']=-1;12 score['A']['G']=score['G']['A& 阅读全文
posted @ 2014-01-18 19:16 N_ll 阅读(164) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1166树状数组模板题 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int N=50005; 7 int a[N],c[N]; 8 int n; 9 int lowbit(int x)10 {11 return x&(-x);12 }13 int sum(int x)14 {15 int ans = 0;16 while(x > 0)17 {18 an... 阅读全文
posted @ 2014-01-17 09:55 N_ll 阅读(121) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 21 下一页