标签:display gif color nbsp using freopen void operator 起点
/* 因为选的楼是个集合,与顺序无关 而且总花费=c[1]+c[2]+c[3]+|h[1]-h[2]|+|h[2]-h[3]| 我们规定走的顺序从高到低,那么绝对值就可以去掉 所以就可以约掉中间的 枚举起点终点就行了 */ #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstdlib> #define maxn 51 using namespace std; int n,t,Ans; struct node{ int c,h; bool operator < (const node b)const{ return c<b.c; } }q[maxn]; int main(){ freopen("meet.in","r",stdin);freopen("meet.out","w",stdout); // freopen("Cola.txt","r",stdin); scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&q[i].c); for(int i=1;i<=n;i++)scanf("%d",&q[i].h); scanf("%d",&t); sort(q+1,q+n+1); for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){//枚举起点和终点 int now=t; int mx=max(q[i].h,q[j].h),mn=min(q[i].h,q[j].h); now-=abs(q[i].h-q[j].h)+q[i].c+q[j].c; if(now<0)continue; int ans=2; for(int k=1;k<=n;k++){ if(k==i||k==j||q[k].h>mx||q[k].h<mn)continue; if(now-q[k].c<0)continue; now-=q[k].c;ans++; } Ans=max(Ans,ans); } } if(Ans==0&&q[1].c<=t)Ans=1; printf("%d",Ans); } /* 10 19076 5807 413 6068 16699 28657 21980 12842 1668 21332 15929 15552 10742 29857 14248 14255 1464 29941 4132 25874 60081 */
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define mod 47680453 using namespace std; int n,s,a[1226],q[10],q1[10],b[1226],nn; struct node{ int x1,x2,x3,x4,x5; }ans[1000]; bool vis[50000000]; int has(){ int res=1; for(int i=1;i<=n;i++){ res=(res*37+q1[i])%mod; } return res; } void check(){ int t=0; for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ b[++t]=q[i]+q[j]; } } sort(b+1,b+nn+1); for(int i=1;i<=nn;i++){ if(b[i]!=a[i])return; } for(int i=1;i<=n;i++)q1[i]=q[i]; sort(q1+1,q1+n+1); node now;now.x1=q1[1];now.x2=q1[2];now.x3=q1[3];now.x4=q1[4];now.x5=q1[5]; int ha=has(); if(!vis[ha]){ vis[ha]=1; ans[++s]=now; } } void dfs(int pos){ if(pos==n+1){ check(); return; } for(int i=10;i>=1;i--){ q[pos]=i; dfs(pos+1); } } bool cmp(node u,node v){ if(u.x1!=v.x1)return u.x1>v.x1; if(u.x2!=v.x2)return u.x2>v.x2; if(u.x3!=v.x3)return u.x3>v.x3; if(u.x4!=v.x4)return u.x4>v.x4; if(u.x5!=v.x5)return u.x5>v.x5; } int main(){ freopen("city.in","r",stdin);freopen("city.out","w",stdout); // freopen("Cola.txt","r",stdin); scanf("%d",&n);nn=n*(n-1)/2; for(int i=1;i<=nn;i++)scanf("%d",&a[i]); sort(a+1,a+nn+1); dfs(1); printf("%d\n",s); sort(ans+1,ans+s+1,cmp); for(int i=1;i<=s;i++){ if(n==5)printf("%d %d %d %d %d\n",ans[i].x1,ans[i].x2,ans[i].x3,ans[i].x4,ans[i].x5); if(n==4)printf("%d %d %d %d\n",ans[i].x1,ans[i].x2,ans[i].x3,ans[i].x4); if(n==3)printf("%d %d %d\n",ans[i].x1,ans[i].x2,ans[i].x3); if(n==2)printf("%d %d\n",ans[i].x1,ans[i].x2); if(n==1)printf("%d\n",ans[i].x1); } return 0; }
#include<iostream> #include<cstdio> #define maxn 100010 using namespace std; int n,m,a[maxn]; struct node{ int l,r,p,v; }q[maxn]; bool flag=1; int main(){ freopen("light.in","r",stdin);freopen("light.out","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=m;i++){ scanf("%d%d%d%d",&q[i].l,&q[i].r,&q[i].p,&q[i].v); } for(int i=1;i<=m;i++){ int ans=0; for(int j=q[i].l;j<=q[i].r;j++){ if(a[j]%q[i].p==q[i].v)ans++; } printf("%d\n",ans); } }
预计得分100+30+30 实际得分100+30+30 三个题写的都不是正解,其中T1是化简式子之后胡邹的一个算法 T2T3都是暴力 这次模拟赛暴力虽然打的没什么技巧,但是不该丢的分都没有丢
标签:display gif color nbsp using freopen void operator 起点
原文地址:http://www.cnblogs.com/thmyl/p/7749431.html