标签:cst algorithm load git ... none head click names
//T1 铺地毯 #include <cstdio> #define N 10005 int x,y,n,a[N],b[N],g[N],k[N]; int main() { scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d%d%d%d",&a[i],&b[i],&g[i],&k[i]); scanf("%d%d",&x,&y); for(int i=n;i>=1;--i) if(a[i]<=x&&x<=a[i]+g[i]-1&&b[i]<=y&&y<=b[i]+k[i]-1) {printf("%d",i);return 0;} printf("-1\n"); return 0; } //T2 进制转换 #include <ctype.h> #include <cstdlib> #include <cstdio> void read(int &x) { x=0;bool f=0; char ch=getchar(); while(!isdigit(ch)) {if(ch==‘-‘) f=1;ch=getchar();} while(isdigit(ch)) {x=x*10+ch-‘0‘;ch=getchar();} x=f?(~x)+1:x; } int m,n,base,ans[10005],num; int main() { read(n); m=n; read(base); while(abs(n)!=0) { ans[num]=(abs(base)+n%base)%(abs(base)); n-=ans[num]; n/=base; num++; } printf("%d=",m); for(int i=num-1;i>=0;i--) if(ans[i]<10) printf("%d",ans[i]);else printf("%c",ans[i]+55); printf("(base%d)",base); return 0; } //T3多项式输出 #include <cstdio> int n; int main() { scanf("%d",&n);int k=n+1; for(int a;k--;) { scanf("%d",&a); if(a==0) continue; if(k==n&&a!=1&&a!=-1) printf("%dx^%d",a,k); else if(k==n&&a==1) printf("x^%d",k); else if(k==n&&a==-1) printf("-x^%d",k); else if(k==0) { if(a>0) printf("+%d",a); else printf("%d",a); } else if(k==1) { if(a==1) printf("+x"); else if(a>0) printf("+%dx",a); else if(a<0) printf("%dx",a); else if(a==-1) printf("-x"); } else if(a==1) printf("+x^%d",k); else if(a>0) printf("+%dx^%d",a,k); else if(a==-1) printf("-x^%d",k); else printf("%dx^%d",a,k); } return 0; } //T4机器翻译 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stack> using namespace std; int m,n,i,head,tail,j,yc=0,ans,xl[1010]; bool cz[1010]; int z[1010]; int main() { cin>>n>>m; for(i=0;i<m;++i) { cin>>xl[i]; if(cz[xl[i]]==1) continue; if(cz[xl[i]]==0&&yc<n) { ans++; cz[xl[i]]=1; z[head++]=xl[i]; yc++; } else { ans++; cz[xl[i]]=1; z[head++]=xl[i]; cz[z[tail++]]=0; } } cout<<ans<<endl; } //T5 排座椅 #include <algorithm> #include <cstdio> #define N 1005 int min(int a,int b) {return a<b?a:b;} struct node { int pos,num; }x[N],y[N]; bool cmp(node a,node b) {return a.num>b.num;} bool comp(node a,node b) {return a.pos<b.pos;} int m,n,k,l,d; int main() { scanf("%d%d%d%d%d",&m,&n,&k,&l,&d); for(int xi,yi,pi,qi;d--;) { scanf("%d%d%d%d",&xi,&yi,&pi,&qi); if(xi==pi) { y[min(yi,qi)].num++; y[min(yi,qi)].pos=min(yi,qi); } if(yi==qi) { x[min(xi,pi)].num++; x[min(xi,pi)].pos=min(xi,pi); } } std::sort(x+1,x+1+n,cmp);std::sort(y+1,y+1+n,cmp); std::sort(x+1,x+1+k,comp);std::sort(y+1,y+1+l,comp); for(int i=1;i<=k;++i) printf("%d ",x[i].pos); printf("\n"); for(int i=1;i<=l;++i) printf("%d ",y[i].pos); return 0; } //T6 笨小猴 #include<iostream> #include<cmath> #include<cstdio> #include<cstring> using namespace std; int cs[122]; bool q[122]; int main() { int maxn=0,minn=999999; char s[101]; gets(s); for(int i=0;i<strlen(s);++i) { cs[s[i]]++; q[s[i]]=1; } for(int i=97;i<=122;++i) { if(cs[i]>maxn&&q[i]==1) maxn=cs[i]; if(cs[i]<minn&&q[i]==1) minn=cs[i]; } int d=maxn-minn; bool a=1; for(int i=2;i<=sqrt(d);++i) { if(d%i==0) { a=0; break; } } if(a==1&&d!=0&&d!=1) { cout<<"Lucky Word"<<endl; cout<<d; } if(d==0||d==1||a==0) { cout<<"No Answer"<<endl; cout<<0; } return 0; }
哎 阿龙要求刷动归 计划又被打乱了 无奈啊 (#‵′)
洛谷——普及练习场 普及组选手可冲刺训练,提高组选手亦可在此巩固基础。(Loading...)
标签:cst algorithm load git ... none head click names
原文地址:http://www.cnblogs.com/ruojisun/p/7424206.html