20160813 PM Training Record

Source: Internet
Author: User

* In the afternoon I heard the lecture was simple, and was pulled to the next door to do a tasty hu not to write the question

T1

Jiangsu Province when the choice of a topic, Shao crazy at that time with my mouth hu over this problem

Let's just not think about 1.

Then we select an element, when the second one is added, the parity of the two is different, when the third number is added, it is definitely not satisfied.

So we're going to have to give you a 1 count, and then we'll mess up.

intn,a[1234];BOOLnp[33333333];inttot,pr[8001234];Const intn=30000000;voidsieve () { for(intI=2; i<=n;i++){        if(!np[i]) pr[++tot]=i;  for(intj=1; j<=tot&&i*pr[j]<=n;j++) {Np[i*pr[j]]=1; if(i%pr[j]==0) Break; }    }    return;}intFintcnt1) {    intans=0; if(CNT1) for(intI=1; i<=n;i++)if(a[i]!=1)if(!np[a[i]+1])return 1; Else         return 0;}intMain () {Freopen ("prime.in","R", stdin); Freopen ("Prime.out","W", stdout);    Sieve (); CIN>>N; intL=0, cnt1=0, is2=0;  for(intI=1; i<=n;i++) cin>>a[i],cnt1+= (a[i]==1); Sort (a+1, a+n+1); if(n==2) {cout<<n<<endl<<a[1]<<' '<<a[2]; return 0; }     for(intI=1; i<=n;i++) for(intj=1; j<=n;j++)if(I^J)if(!np[a[i]+a[j]]) L=2; if(! L for(intI=1; i<=n;i++)if(!np[a[i]]) L=1; if(l==1) {printf ("1\n"); for(inti=n;i>=1; i--)if(!Np[a[i]]) {printf ("%d", A[i]);return 0; }    }intT; if(Cnt1+f (CNT1) <=2) {puts ("2");  for(inti=n;i>=1; i--) for(intj=i-1; j>=1; j--){        if(I^J)if(!np[a[i]+a[j]]) printf ("%d%d\n", A[j],a[i]);return 0;} }Else{L=cnt1+f (cnt1); cout<<L<<Endl;  for(intI=1; i<=cnt1;i++) printf ("%d",1);  for(inti=n;i>=1; i--)if(!np[a[i]+1]) {printf ("%d", A[i]);return 0; }    }}

Then I went away.

T2

will only N^2DP

F[I][J][0] The optimal value of the first I put J Flower, I do not put

F[I][J][1] The optimal value of the first I put J Flower, I put

Transfer

intf[3010][3010][2],a[3010];intn,m;intMain () {Freopen ("flower.in","R", stdin); Freopen ("Flower.out","W", stdout); scanf ("%d%d",&n,&m);  for(intI=1; i<=n;i++) scanf ("%d",&A[i]);  for(intI=1; i<=n;i++) for(intj=1; j<=m;j++) f[i][j][0]=f[i][j][1]=-2000000000; f[1][1][1]=a[1];  for(intI=2; i<=n;i++) {f[i][0][0]=0;  for(intj=1; j<=m;j++) {f[i][j][1]=f[i-1][j-1][0]+A[i]; f[i][j][0]=max (f[i-1][j][0],f[i-1][j][1]); }    }    intans=f[n][m][0];  for(intI=1; i<=n;i++) for(intj=1; j<=m;j++) f[i][j][0]=f[i][j][1]=-2000000000; f[1][0][0]=0;  for(intI=2; i<=n;i++) {f[i][0][0]=0;  for(intj=1; j<=m;j++) {f[i][j][1]=f[i-1][j-1][0]+A[i]; f[i][j][0]=max (f[i-1][j][0],f[i-1][j][1]); }} ans=max (Ans,max (f[n][m][0],f[n][m][1])); if(m>n/2) cout<<"error!"; Elsecout<<ans;//cout<< (M>N/2? ") Error! ": ans);    return 0;}

T3

Given a tree, you can delete an edge, divide it into two unicom blocks, and minimize the sum of two diameters.

Won't do

20160813 PM Training Record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.