华东交通大学2014年ACM“双基”程序设计竞赛(部分水题)
来源:互联网 发布:linux openstack 安装 编辑:程序博客网 时间:2024/04/30 10:36
目前还是个渣渣,只能做做水题,暂且把能在规定时间内做出来的题发出来
A题:题目链接http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1001&cid=25698&problem=Problem%20%20A
简单的字符输入及计数,注意循环的问题就没问题
#include <cmath>#include <cctype>#include <cstdio>#include <string>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define id 10001#define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))int main(){ int t; scanf("%d",&t); while( t-- ) { int n,m; int flag = 0; int i = 0,j = 0,p = 0,q = 0,x = 0, y = 0; char a; cin >> n >> m; a = getchar(); while(n--){ for(;;) { a=getchar(); if (a == '\n') break; if (a == 'I') i++; if (a == 'L') j++; if (a == 'O') p++; if (a == 'V') q++; if (a == 'E') x++; if (a == 'U') y++; } } int b =0; b = Min(i,j); b = Min(b,p); b = Min(b,q); b = Min(b,x); b = Min(b,y); if (b >= m){ cout << "KK will have a girlfriend!"<<endl; } else{ cout << "KK can only have gay friend~"<<endl; } } return 0;}
C题:http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1003&cid=25698&problem=Problem%20%20C
看得懂题意应该就能写出来吧,确实简单
#include <cmath>#include <cctype>#include <cstdio>#include <string>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define id 10001#define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))int x[id];float y[id];int main(){ int t; scanf("%d",&t); while( t-- ) { memset(x,0,sizeof(x[id])); int n,k; int i =0; cin>>n; while(n--){ cin>>x[i]; i++; } cin>>k; int m = k; while(k--){ int l,r; int sum = 0; cin>>l>>r; for (int s = l;s <= r;s++) sum += x[s-1]; y[k] = (float)sum / (r-l+1); printf("%.2f\n",y[k]); } } return 0;}
D题:http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1004&cid=25698&problem=Problem%20%20D
数组输入加上排序就OK了,不过要注意输出格式问题
#include <cmath>#include <cctype>#include <cstdio>#include <string>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define id 10001#define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))int x[id];int main(){ int t; scanf("%d",&t); while( t-- ) { memset(x,0,sizeof(x[id])); int n,k; int i =0; cin>>n; while(n--){ cin>>x[i]; i++; } sort(x,x+i); for (int j = 0; j < i-1; j++){ cout << x[j] << " "; } cout << x[i-1]<<endl; } return 0;}
这次比赛的题让我感觉自己还是只会做简单题,对于有难度的题,还是会无从下手,以后要加强思维能力的训练,对算法的学习和理解都还远远不够,还是要多多刷题,期待量变引起质变的那天。每次都会有一题能做出来却总是WA,没找到错误,在这里也贴出来吧,留待有空再看看。
B题:http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1002&cid=25698&problem=Problem%20%20B
感觉就是一道简单的物理题,把各种情况考虑进去,但还是没过(也许是太长时间不接触物理脑子不行了)。
#include <cmath>#include <cctype>#include <cstdio>#include <string>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define g 9.8#define Max(a,b) ((a)>(b)?(a):(b))#define Min(a,b) ((a)<(b)?(a):(b))int main(){ int t; scanf("%d",&t); while( t-- ) { int x1,x2,y,vx; double vy,s; cin>>x1>>x2>>y>>vx; if (x2 < x1 || (x1 == x2 && vx != 0) || (vx == 0 && x1 != x2) || y < 0 || vx < 0 ){ cout <<"Xue di so diao can fly"<<endl; continue; } if (y == 0) { vy = 0; printf("%.2f\n",vy); continue; } if (vx != 0 && x1 != x2){ s = (double)(x2-x1)/vx; vy = (double)(y + s * s * g / 2) / s; } if (vx == 0 && x1 == x2) vy = sqrt(2*g*y); printf("%.2f\n",vy); } return 0;}
0 0
- 华东交通大学2014年ACM“双基”程序设计竞赛(部分水题)
- 华东交通大学2014年ACM“双基”程序设计竞赛解题报告
- 华东交通大学2014年ACM“双基”程序设计竞赛解题报告
- 华东交通大学2014年ACM“双基”程序设计竞赛部分解题报告
- 华东交通大学2013年ACM“双基”程序设计竞赛 解题报告
- 华东交通大学2013年ACM“双基”程序设计竞赛获奖公示
- 华东交通大学2013年ACM“双基”程序设计竞赛
- 华东交通大学2015年ACM“双基”程序设计竞赛
- 华东交通大学2016年ACM“双基”程序设计竞赛
- 华东交通大学2016年ACM“双基”程序设计竞赛 A:简单题
- 华东交通大学2013ACM“双基”程序设计竞赛 解题报告
- 华东交通大学2016年ACM“双基”程序设计竞赛 H:毛线数列最值
- 第七届北京交通大学ACM程序设计竞赛网络预赛一
- 第七届北京交通大学ACM程序设计竞赛网络预赛二
- ECJTU16年ACM“双基”程序设计竞赛1007题
- 华东交通大学2016届新生选拔赛:1010 我是签到题
- 第四届“图灵杯”NEUQ-ACM程序设计竞赛部分题解
- 2014年第七届河南省ACM大学生程序设计竞赛有感
- Linux Socket编程
- VC++6.0注释快捷键设置
- C++实现感知器学习作业1
- LabTalk 编程第二章--运算符
- 队列
- 华东交通大学2014年ACM“双基”程序设计竞赛(部分水题)
- 学好英语,开启新的世界。
- 带参数的main函数
- 简单FutureTask
- 第十四周项目二带姓名的成绩单(3)
- 第14周项目2-带姓名的成绩单(2、按姓名排序)
- Ajax中Get请求与Post请求的区别
- Java多线程
- matlab 图片批量读取