Problem Description To improve the organization of his farm, Farmer John labels each of his N (1 <= N <= 5,000) cows with a distinct serial number in the range 1..20,000. Unfortunately, he is unaware that the cows interpret some serial numbers as be…
#include<iostream> #include<stdio.h> #include<string.h> #include<cmath> using namespace std; const int maxn=20017; int s[maxn]; int main() { int n,m; int i,j; memset(s,0,sizeof(s)); /*s[1]=1;//埃筛素数 for(i=2; i<maxn; i++) { if(s[i…
看懂: Max Factor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3089 Accepted Submission(s): 985 Problem Description To improve the organization of his farm, Farmer John labels each of his N…
题目链接:hdu 3415 Max Sum of Max-K-sub-sequence 题意: 给你一串形成环的数,让你找一段长度不大于k的子段使得和最大. 题解: 我们先把头和尾拼起来,令前i个数的和为sum[i]. 然后问题变成了求一个max{sum[i]-sum[j]}(i-k<j<i) 意思就是对于每一个sum[i],我们只需要找一个满足条件的最小的sum[j],然后我们就可以用一个单调队列来维护. #include<bits/stdc++.h> #define F(i,a…
题目链接:hdu 2993 MAX Average Problem 题意: 给一个长度为 n 的序列,找出长度 >= k 的平均值最大的连续子序列. 题解: 这题是论文的原题,请参照2004集训队论文<周源--浅谈数形结合思想在信息学竞赛中的应用> 这题输入有点大,要加读入优化才能过. #include<bits/stdc++.h> #define F(i,a,b) for(int i=a;i<=b;++i) using namespace std; int tot;…