[NOIP2012] Universal group

Source: Internet
Author: User
Tags cmath

Treasure Hunt

Big simulation

1#include <iostream>2#include <cmath>3#include <algorithm>4 using namespacestd;5 intn,m;6 intro[10500][ Max];//Brand7 intru[10500][ Max];//This room is upstairs .8 inth[20000]={0};9 intsx=0;Ten intstart; One intLV; A intMain () { -  -     inti,j; thescanf"%d%d",&n,&m); -      for(i=1; i<=n;i++) -        for(j=0; j<m;j++){ -scanf"%d%d",&ru[i][j],&ro[i][j]); +h[i]+=Ru[i][j]; -       } +scanf"%d",&start); A //printf ("%d\n", n); at      for(lv=1; lv<=n;lv++){ -         intx=Ro[lv][start]; -sx+=x; - //printf ("Test%d\n", SX); -x=x%h[lv]+H[LV]; -x=x-Ru[lv][start]; in          while(x>0){ -start++; tostart%=m; +x-=Ru[lv][start]; -         } the         //lv++; *     } $sx%=20123;Panax Notoginsengprintf"%d", SX); -     return 0; the}

Pendulum Flower

Group Backpack

1#include <iostream>2#include <cmath>3#include <algorithm>4 using namespacestd;5 Long Longf[ $];6 inta[ $];//No. I flower number7 intMain () {8     intn,m;9scanf"%d%d",&n,&m);Ten     inti,j; One      for(i=1; i<=n;i++) scanf ("%d",&a[i]); Af[0]=1; -      for(i=1; i<=n;i++){ -          for(j=m;j>=1; j--){ the             intMi=min (a[i],j); -              for(intC=1; c<=mi;c++) -F[j]= (F[j]+f[j-c])%1000007; -         } +     } -f[m]%=1000007; + //printf ("%d", f[m]); Acout<<F[m]; at     return 0; -}

Mass factor decomposition

Violent enumeration can be judged.

A long time ago code style, some weird

#include <iostream>#include<cmath>#include<algorithm>using namespacestd;intN;intc,sq;intx, y;BOOLPdintp) {    inti,sqt=sqrt (p);  for(i=2; i<=sqt;i++){        if(p%i==0)return 0; }    return 1;}intMain () {scanf ("%d",&N); C=n/2; Sq=sqrt (n); inti,j; if((c&1)==0) c+=1;  for(i=2; i<=sq;i++)      if(PD (i)) {intd=n/i; if(i*d==N) {printf ("%d", D); return 0; }      }    return 0;}

Culture Tour

Floyd

↑ Not a positive solution, just because the data water is mixed up in the past

1#include <iostream>2#include <algorithm>3#include <cmath>4 using namespacestd;5 Const intinf=10000000;6 intc[ the];7 intfl[ -][ -];8 intmp[ -][ -];9 //int DFS () {Ten      One //} A intMain () { -     inti,j,n,k,m,s,t; -     //inch thescanf"%d%d%d%d%d",&n,&k,&m,&s,&t); -      for(i=1; i<=n;i++){ -scanf"%d",&c[i]); -     } +      for(i=1; i<=k;i++) -       for(j=1; j<=k;j++) +scanf"%d",&fl[i][j]); A      for(i=1; i<=n;i++) at       for(j=1; j<=n;j++){ -          if(i!=j) -mp[i][j]=inf; -      } -      for(i=1; i<=m;i++){ -         intu,v,d; inscanf"%d%d%d",&u,&v,&d); -mp[u][v]=min (mp[u][v],d); tomp[v][u]=Mp[u][v]; +     } -      for(i=1; i<=n;i++) the       for(j=1; j<=n;j++){ *          if(fl[c[i]][c[j]]==1) mp[j][i]=inf; $      }Panax Notoginseng      for(k=1; k<=n;k++) -        for(i=1; i<=n;i++) the          for(j=1; j<=n;j++){ +             if(mp[i][k]+mp[k][j]<Mp[i][j]) { Amp[i][j]=mp[i][k]+Mp[k][j]; the             } +         } -     if(Mp[s][t]==inf) printf ("-1"); $     Elseprintf"%d", Mp[s][t]); $     return 0; -      -}

[NOIP2012] Universal group

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.