"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 1001-1006
来源:互联网 发布:知画生孩子是第几集 编辑:程序博客网 时间:2024/05/29 04:51
1001 Solving Order
水,签到
/* ***********************************************Author :angon************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define REP(i,k,n) for(int i=k;i<n;i++)#define REPP(i,k,n) for(int i=k;i<=n;i++)#define scan(d) scanf("%d",&d)#define scann(n,m) scanf("%d%d",&n,&m)#define mst(a,k) memset(a,k,sizeof(a));#define LL long long#define maxn 1005#define mod 100000007/*inline int read(){ int s=0; char ch=getchar(); for(; ch<'0'||ch>'9'; ch=getchar()); for(; ch>='0'&&ch<='9'; ch=getchar())s=s*10+ch-'0'; return s;}inline void print(int x){ if(!x)return; print(x/10); putchar(x%10+'0');}*/struct node{ char s[100]; int x;}p[12];bool cmp(node n1,node n2){ return n1.x>n2.x;}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int t,n; scan(t); while(t--) { scan(n); for(int i=0;i<n;i++) { scanf("%s",p[i].s); scan(p[i].x); } sort(p,p+n,cmp); for(int i=0;i<n;i++) { if(i<n-1) printf("%s ",p[i].s); else printf("%s\n",p[i].s); } } return 0;}
1002 Desert
签到
/* ***********************************************Author :angon************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define REP(i,k,n) for(int i=k;i<n;i++)#define REPP(i,k,n) for(int i=k;i<=n;i++)#define scan(d) scanf("%d",&d)#define scann(n,m) scanf("%d%d",&n,&m)#define mst(a,k) memset(a,k,sizeof(a));#define LL long long#define maxn 1005#define mod 100000007/*inline int read(){ int s=0; char ch=getchar(); for(; ch<'0'||ch>'9'; ch=getchar()); for(; ch>='0'&&ch<='9'; ch=getchar())s=s*10+ch-'0'; return s;}inline void print(int x){ if(!x)return; print(x/10); putchar(x%10+'0');}*/int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int t,n; scan(t); while(t--) { scan(n); printf("1"); for(int i=0;i<n-1;i++) printf("0"); printf("\n"); } return 0;}
1003 Luck Competition
简单算一下;推出X的公式 x<=2*(double)sum/(3.0*(double)n-2);/* ***********************************************Author :angon************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define REP(i,k,n) for(int i=k;i<n;i++)#define REPP(i,k,n) for(int i=k;i<=n;i++)#define scan(d) scanf("%d",&d)#define scann(n,m) scanf("%d%d",&n,&m)#define mst(a,k) memset(a,k,sizeof(a));#define LL long long#define maxn 1005#define mod 100000007#define esp 1e-8/*inline int read(){ int s=0; char ch=getchar(); for(; ch<'0'||ch>'9'; ch=getchar()); for(; ch>='0'&&ch<='9'; ch=getchar())s=s*10+ch-'0'; return s;}inline void print(int x){ if(!x)return; print(x/10); putchar(x%10+'0');}*/int num[10000];int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int t; scanf("%d",&t); while(t--) { int n,i,cont=1,m; int sum=0,minn=999999999; double a,b,k; scanf("%d",&n); for(i=0;i<n-1;i++) { scanf("%d",&num[i]); sum+=num[i]; } b=2*(double)sum/(3.0*(double)n-2); m=b; for(i=0;i<n-1;i++) { if(num[i]==m) cont++; } k=1.0/(double)cont; printf("%d %.2f\n",m,k); } return 0;}
1004 Clock
模拟一下时钟的运转,仔细在纸上推一下,不难想只是比较啰嗦
/* ***********************************************Author :angon************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define REP(i,k,n) for(int i=k;i<n;i++)#define REPP(i,k,n) for(int i=k;i<=n;i++)#define scan(d) scanf("%d",&d)#define scann(n,m) scanf("%d%d",&n,&m)#define mst(a,k) memset(a,k,sizeof(a));#define LL long long#define maxn 1005#define mod 100000007/*inline int read(){ int s=0; char ch=getchar(); for(; ch<'0'||ch>'9'; ch=getchar()); for(; ch>='0'&&ch<='9'; ch=getchar())s=s*10+ch-'0'; return s;}inline void print(int x){ if(!x)return; print(x/10); putchar(x%10+'0');}*/int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int h,m,s; int cas=1; while(~scanf("%d:%d:%d",&h,&m,&s)) { double a; scanf("%lf",&a); double x=30*h+1/2.0*m+1/120.0*s; double y=6*m+1/10.0*s; double v = (y-x); if(v>180) v-=360; else if(v < -180) v += 360; //printf("v=%lf\n",v); double c; if(v<a && v>=-a) { c=a-v; } else if(v>=a) { c=360-v-a; } else { c=fabs(v+a); } double t=c*120.0/11.0; s += t; m+= s/60; s %= 60; h += m/60; m%=60; h%=12; printf("Case #%d: ",cas++); if(h<10) printf("0%d:",h); else printf("%d:",h); if(m<10) printf("0%d:",m); else printf("%d:",m); if(s<10) printf("0%d\n",s); else printf("%d\n",s); } return 0;}
1005 GirlCat
DFS,直接dfs搜就是了,非常直接,没用什么优化也过了,数据不是很强
/* ***********************************************Author :angon************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define REP(i,k,n) for(int i=k;i<n;i++)#define REPP(i,k,n) for(int i=k;i<=n;i++)#define scan(d) scanf("%d",&d)#define scann(n,m) scanf("%d%d",&n,&m)#define mst(a,k) memset(a,k,sizeof(a));#define LL long long#define maxn 1005#define mod 100000007/*inline int read(){ int s=0; char ch=getchar(); for(; ch<'0'||ch>'9'; ch=getchar()); for(; ch>='0'&&ch<='9'; ch=getchar())s=s*10+ch-'0'; return s;}inline void print(int x){ if(!x)return; print(x/10); putchar(x%10+'0');}*/char Map[1005][1005];int xx[4]={1,0,-1,0};int yy[4]={0,1,0,-1};char s1[5]="girl";char s2[5]="cat";int n,m;int dfs1(int x,int y,int step){ if(x<0 || x>=n || y<0 || y>=m)return 0; int cnt = 0; if(Map[x][y]!=s1[step]) return 0; if(step==3)return 1; for(int i=0;i<4;i++) { cnt+=dfs1(x+xx[i],y+yy[i],step+1); } return cnt;}int dfs2(int x,int y,int step){ if(x<0 || x>=n || y<0 || y>=m)return 0; int cnt = 0; if(Map[x][y]!=s2[step]) return 0; if(step==2)return 1; for(int i=0;i<4;i++) { cnt+=dfs2(x+xx[i],y+yy[i],step+1); } return cnt;}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int t; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { scanf("%s",Map[i]); } int girl=0,cat=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { girl+=dfs1(i,j,0); cat+=dfs2(i,j,0); } } cout<<girl<<" "<<cat<<endl; } return 0;}
1006 Combine String
一开始暴力匹配WA了,发现有 aff asd asaffd 这样的数据过不了。最后队友DP做出来的。
/* ***********************************************Author :angon************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;#define REP(i,k,n) for(int i=k;i<n;i++)#define REPP(i,k,n) for(int i=k;i<=n;i++)#define scan(d) scanf("%d",&d)#define scann(n,m) scanf("%d%d",&n,&m)#define mst(a,k) memset(a,k,sizeof(a));#define LL long long#define maxn 1005#define mod 100000007/*inline int read(){ int s=0; char ch=getchar(); for(; ch<'0'||ch>'9'; ch=getchar()); for(; ch>='0'&&ch<='9'; ch=getchar())s=s*10+ch-'0'; return s;}inline void print(int x){ if(!x)return; print(x/10); putchar(x%10+'0');}*/char a[2005],b[2005],c[2005];int dp[2005][2005];int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); while(~scanf("%s",a+1)) { scanf("%s",b+1); scanf("%s",c+1); int lena=strlen(a+1); int lenb=strlen(b+1); int lenc=strlen(c+1); if(lena + lenb != lenc) { cout<<"No"<<endl; continue; } int i=0,j=0; memset(dp,0,sizeof dp); dp[0][0]=1; for(i=0;i<=lena;i++) { for(j=0;j<=lenb;j++) { if(i)dp[i][j] += dp[i-1][j] && (a[i] == c[i+j]); if(j)dp[i][j] += dp[i][j-1] && (b[j] == c[i+j]); } } if(dp[lena][lenb])cout<<"Yes"<<endl; else cout<<"No"<<endl; } return 0;}
0 0
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 1001-1006
- hdu_5705_Clock("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)解题思路
- HDU "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 Combine String
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5702
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5703
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5704
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5705
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5706
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5707
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 Combine String
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)解题思路
- hdu_5707_Combine String("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场-1001-Solving Order
- "巴卡斯杯" 中国大学生程序设计竞赛
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1001
- 2016中国大学生程序设计竞赛
- 2017中国大学生程序设计竞赛
- LaTeX数学公式中的空格
- VS2010/MFC 读写excel文件 操作类
- angularjs对json数据的操作--收货地址列表
- 函数返回局部变量的问题
- nsci.txt 是什么?
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 1001-1006
- jquery cookie记住用户名和密码(使用方法)
- iOS学习- 03 控件
- 几种JS转跳页面方式
- Ubuntu利用tasksel安装配置lamp环境
- (C++)使用模板在编译期计算阶乘
- 网站系统的“用户登录”
- 利用makefile将添加的资源文件编译到Android系统中
- ACdream 1071 神奇的%系列一 筛选法