华东交通大学2014年ACM“双基”程序设计竞赛(部分水题)
2014-11-30 12:58
330 查看
目前还是个渣渣,只能做做水题,暂且把能在规定时间内做出来的题发出来
A题:题目链接http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1001&cid=25698&problem=Problem%20%20A
简单的字符输入及计数,注意循环的问题就没问题
C题:http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1003&cid=25698&problem=Problem%20%20C
看得懂题意应该就能写出来吧,确实简单
D题:http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1004&cid=25698&problem=Problem%20%20D
数组输入加上排序就OK了,不过要注意输出格式问题
这次比赛的题让我感觉自己还是只会做简单题,对于有难度的题,还是会无从下手,以后要加强思维能力的训练,对算法的学习和理解都还远远不够,还是要多多刷题,期待量变引起质变的那天。每次都会有一题能做出来却总是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;
}
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;
}
相关文章推荐
- 华东交通大学2014年ACM“双基”程序设计竞赛部分解题报告
- 华东交通大学2014年ACM“双基”程序设计竞赛解题报告
- 华东交通大学2014年ACM“双基”程序设计竞赛解题报告
- 华东交通大学2017年ACM“双基”程序设计竞赛 1005
- 华东交通大学2016年ACM“双基”程序设计竞赛 1008
- 华东交通大学2017年ACM“双基”程序设计竞赛 1009
- 华东交通大学2016年ACM“双基”程序设计竞赛 1001
- 华东交通大学2016年ACM“双基”程序设计竞赛 1002
- 华东交通大学2016年ACM“双基”程序设计竞赛 1004
- 华东交通大学2016年ACM“双基”程序设计竞赛 1003
- 华东交通大学2016年ACM“双基”程序设计竞赛 1005
- 华东交通大学2015年ACM“双基”程序设计竞赛1007
- 华东交通大学2016年ACM“双基”程序设计竞赛 1007
- 华东交通大学2015年ACM“双基”程序设计竞赛
- 华东交通大学2016年ACM“双基”程序设计竞赛 1009
- 华东交通大学2013年ACM“双基”程序设计竞赛
- 华东交通大学2015年ACM“双基”程序设计竞赛1001
- 华东交通大学2013年ACM“双基”程序设计竞赛 解题报告
- 华东交通大学2013年ACM“双基”程序设计竞赛获奖公示
- 华东交通大学2017年ACM“双基”程序设计竞赛 1001