Heim  >  Artikel  >  Web-Frontend  >  Codeforces Round #FF (Div. 1)-A,B,C_html/css_WEB-ITnose

Codeforces Round #FF (Div. 1)-A,B,C_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:01:13984Durchsuche

A:DZY Loves Sequences

一开始看错题了。。sad。

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

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

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

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

#include<iostream>#include<stdio.h>#include<algorithm>#include<stdlib.h>#include<string.h>using 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 dp else num if>=a[i+1])        {            if(dp[i][1]<dp dp num for i="1;" maxx="max(maxx,dp[i][0]);" cout main while scanf memset if>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]<dp dp num if int maxx="-1;" for i="1;" cout dos return>B:DZY Loves Modification  <p></p>  <p>我们可以发现选择一个横行,竖行的大小顺序不变,只是每一个竖行都下降了p。</p>  <p>所以我们可以枚举选择了x个横行,y个竖行。</p>  <p></p>  <pre name="code" class="sycode">#include<iostream>#include<stdio.h>#include<algorithm>#include<stdlib.h>#include<string.h>#include<queue>using namespace std;#define maxn 1100#define LL __int64int mp[maxn][maxn];int hh[maxn];int ll[maxn];LL ph[1100000];LL pl[1100000];priority_queue<int>que;int n,m,k,p;void chu(){    ph[0]=pl[0]=0;    while(!que.empty())que.pop();    for(int i=1;iC:DZY Loves Fibonacci Numbers  <p></p>  <p>主要是两个性质:</p>  <p>1,两个斐波那契数列相加依然是一个斐波那契数列。</p>  <p>2,根据斐波那契数列的前两项可以O(1)的时间内得出任意一个位置的斐波那契数,和任意长度的斐波那契数列的合。</p>  <p>剩下的东西就是简单的区间求和问题了。</p>  <p></p>  <pre name="code" class="sycode">#include<stdio.h>#include<iostream>#include<stdlib.h>#include<string.h>#include<algorithm>#include<vector>#include<math.h>#include<map>#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,rtr||rr<l if>=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<l cout if>=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<maxn fib int n while creat scanf if else printf return>  <br>  <br>  <br>  <p></p>  <p><br> </p> </maxn></l></l></map></math.h></vector></algorithm></string.h></stdlib.h></iostream></stdio.h>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn