最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

CodeforcesRound#FF(Div.1)-A,B,C_html/css

来源:动视网 责编:小采 时间:2020-11-27 15:54:18
文档

CodeforcesRound#FF(Div.1)-A,B,C_html/css

CodeforcesRound#FF(Div.1)-A,B,C_html/css_WEB-ITnose:A:DZY Loves Sequences 一开始看错题了。sad。 题目很简单,做法也很简单。DP一下就好了。 dp[i][0]:到当前位置,没有任何数改变,得到的长度。 dp[i][1]:到当前位置,改变了一个数,得到的长度 不过需要正向求一遍,然后反向求一遍。 #include
推荐度:
导读CodeforcesRound#FF(Div.1)-A,B,C_html/css_WEB-ITnose:A:DZY Loves Sequences 一开始看错题了。sad。 题目很简单,做法也很简单。DP一下就好了。 dp[i][0]:到当前位置,没有任何数改变,得到的长度。 dp[i][1]:到当前位置,改变了一个数,得到的长度 不过需要正向求一遍,然后反向求一遍。 #include


A:DZY Loves Sequences

一开始看错题了。sad。

题目很简单,做法也很简单。DP一下就好了。

dp[i][0]:到当前位置,没有任何数改变,得到的长度。

dp[i][1]:到当前位置,改变了一个数,得到的长度

不过需要正向求一遍,然后反向求一遍。

#include#include#include#include#includeusing namespace std;#define maxn 110000int dp[maxn][3];int num[maxn];int a[maxn];int n;void dos(int maxx){ memset(dp,0,sizeof(dp)); memset(num,-1,sizeof(num)); for(int i=n; i>=1; i--) { if(a[i]=a[i+1]) { if(dp[i][1]a[i-1]) { dp[i][0]=dp[i-1][0]+1; } else { dp[i][0]=1; } dp[i][1]=dp[i][0]; num[i]=a[i]; if(a[i]>num[i-1]) { if(dp[i][1]
B:DZY Loves Modification

我们可以发现选择一个横行,竖行的大小顺序不变,只是每一个竖行都下降了p。

所以我们可以枚举选择了x个横行,y个竖行。

#include#include#include#include#include#includeusing namespace std;#define maxn 1100#define LL __int64int mp[maxn][maxn];int hh[maxn];int ll[maxn];LL ph[1100000];LL pl[1100000];priority_queueque;int n,m,k,p;void chu(){ ph[0]=pl[0]=0; while(!que.empty())que.pop(); for(int i=1;i<=n;i++) { que.push(hh[i]); } for(int i=1;i<=k;i++) { int x=que.top(); que.pop(); ph[i]=ph[i-1]+(LL)x; x=x-p*m; que.push(x); } while(!que.empty())que.pop(); for(int i=1;i<=m;i++) { que.push(ll[i]); } for(int i=1;i<=k;i++) { int x=que.top(); que.pop(); pl[i]=pl[i-1]+(LL)x; x=x-p*n; que.push(x); }}int main(){ while(~scanf("%d%d%d%d",&n,&m,&k,&p)) { memset(hh,0,sizeof(hh)); memset(ll,0,sizeof(ll)); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf("%d",&mp[i][j]); hh[i]+=mp[i][j]; ll[j]+=mp[i][j]; } } chu(); LL ans=pl[k]; for(int i=1;i<=k;i++) { LL x=(LL)i*(LL)(k-i); x=(LL)x*(LL)p; ans=max(ans,pl[k-i]+ph[i]-x); } cout主要是两个性质:

1,两个斐波那契数列相加依然是一个斐波那契数列。

2,根据斐波那契数列的前两项可以O(1)的时间内得出任意一个位置的斐波那契数,和任意长度的斐波那契数列的合。

剩下的东西就是简单的区间求和问题了。

#include#include#include#include#include#include#include#include#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;#define mem(a,b) (memset(a),b,sizeof(a))#define lmin 1#define rmax n#define lson l,(l+r)/2,rt<<1#define rson (l+r)/2+1,r,rt<<1|1#define root lmin,rmax,1#define now l,r,rt#define int_now int l,int r,int rt#define INF 99999999#define LL __int64#define mod 1000000009#define eps 1e-6#define zero(x) (fabs(x)r||rr=r) { f1[rt]+=fib[l-ll+1]; f2[rt]+=fib[l-ll+2]; sum[rt]+=suan(fib[l-ll+1],fib[l-ll+2],r-l+1); sum[rt]=(sum[rt]+mod)%mod; f1[rt]=f1[rt]%mod; f2[rt]=f2[rt]%mod; return; } push_down(now); updata(ll,rr,lson); updata(ll,rr,rson); push_up(now);}LL query(int ll,int rr,int_now){ if(ll>r||rr=r)return sum[rt]; push_down(now); return (query(ll,rr,rson)+query(ll,rr,lson))%mod;}int main(){ fib[1]=1;fib[2]=1; for(int i=3;i

文档

CodeforcesRound#FF(Div.1)-A,B,C_html/css

CodeforcesRound#FF(Div.1)-A,B,C_html/css_WEB-ITnose:A:DZY Loves Sequences 一开始看错题了。sad。 题目很简单,做法也很简单。DP一下就好了。 dp[i][0]:到当前位置,没有任何数改变,得到的长度。 dp[i][1]:到当前位置,改变了一个数,得到的长度 不过需要正向求一遍,然后反向求一遍。 #include
推荐度:
标签: c (1 b
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top