ACM水题
文章平均质量分 67
静默加载
优秀的判断力来自于经验,但经验来自于错误的判断。在看着别人走过的路时,思考怎么走自己的路。无私奉献不是天方夜谈,有时候,我们也可以做到。
展开
-
HDOJ 2001 计算两点间的距离
测试数据很弱,double就可以过了题目:http://acm.hdu.edu.cn/showproblem.php?pid=2001#include #include int main(){ doublex1,x2,y1,y2; while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF) printf("%.2原创 2015-12-18 18:09:47 · 426 阅读 · 0 评论 -
HDOJ 2002 计算球体积
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2002#include #define PI 3.1415927int main(){ doubler; while(scanf("%lf",&r)!=EOF) printf("%.3lf\n",4/3.0*PI*r*r*r); return0;}原创 2015-12-18 18:09:50 · 528 阅读 · 0 评论 -
HDOJ 2006 求奇数的乘积
i题目:#include int main(){ intsum,i,a,temp; while(scanf("%d",&a)!=EOF) { sum=1; for(i=0;i { scanf("%d",&temp); if(temp%2)原创 2015-12-18 18:09:53 · 400 阅读 · 0 评论 -
HDOJ 2008 数值统计
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2008#include int main(){ intsum1,sum2,sum3,i,a; doubletemp; while(scanf("%d",&a),a) { sum1=sum2=sum3=0; for(i=0;i原创 2015-12-18 18:09:55 · 370 阅读 · 0 评论 -
HDOJ 2019 数列有序!
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2019#include #include #include using namespace std;int main(){ vector a; intn,m,i,b; while(cin>>n>>m,n&&m) { for(i=0;i原创 2015-12-18 18:09:58 · 569 阅读 · 0 评论 -
HDOJ 2020 绝对值排序
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2020#include #include int main(){ inta[250],n,i,j,temp; while(scanf("%d",&n),n) { for(i=0;i scanf("%d",&a[i]);原创 2015-12-18 18:10:01 · 354 阅读 · 0 评论 -
HDOJ 2029 Palindromes _easy v…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2029#include#includeusing namespace std;int f(char a[]){ int i=0,n=strlen(a); while(a[i]==a[n-i-1]&&i i++; return a[i]==a[n-i-1];}int main()原创 2015-12-18 18:10:03 · 496 阅读 · 0 评论 -
HDOJ 2015 偶数求和
题目:#include int main(){ intn,m,j,i,sum; while(scanf("%d%d",&n,&m)!=EOF) { sum=0; for(i=1,j=1;i { sum+=i*2; if(j==m&&i!=n) {原创 2015-12-18 18:10:06 · 363 阅读 · 0 评论 -
HDOJ 2052 Picture
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2052#include #include using namespace std;int main(){ intn,m; while(cin>>n>>m) { string s(n,'-'); string a(n,' ');原创 2015-12-18 18:10:09 · 472 阅读 · 0 评论 -
HDOJ 2054 A == B ?
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2054一道A=B的题,让我提交了四次,很无奈第一次没有考虑长度,第三次没有考虑小数点后面的O,最后一次数组开到10的4次方WA,忍了#include #include void Hou0(char *a, int len){ int flag = 0, sign = 0; for (i原创 2015-12-18 18:10:11 · 576 阅读 · 0 评论 -
HDOJ 2055 An easy problem
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2055#include #include #include using namespace std;int main(){ inti,m,n; chara; map letter; for(i=1;i { letter.insert(原创 2015-12-18 18:10:14 · 520 阅读 · 0 评论 -
HDOJ 2075 A|B?
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2075#include int main(){ intT,a,b; scanf("%d",&T); while(T--) scanf("%d%d",&a,&b),printf("%s\n",a%b==0?"YES":"NO"); return0;原创 2015-12-18 18:10:16 · 639 阅读 · 0 评论 -
HDOJ 2018 母牛的故事
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2018#include #include int a[60];void pro(){ int i; memset(a,0,sizeof(a)); for(i=0;i a[i]=i; for(i=5;i a[i]=a[i-1]+a[i-原创 2015-12-18 18:10:21 · 468 阅读 · 0 评论 -
HDOJ 2084 数塔
题目: http://acm.hdu.edu.cn/showproblem.php?pid=2084#includeint a[102][102];int main(){ intn,i,j,s=0; while(scanf("%d",&n)!=EOF) { for(i=1;i for(j=1;j原创 2015-12-18 18:10:24 · 338 阅读 · 0 评论 -
HDOJ 2503 a/b + c/d
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2503#include int gcd(int a,int b){ return!b?a:gcd(b,a%b);}int main(){ intt,a,b,c,d; scanf("%d",&t); while(t--) { scanf(原创 2015-12-18 18:10:31 · 864 阅读 · 0 评论 -
HDOJ 4302 Holedox Eating
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4302这是第一场比赛的题,做了好长时间没有做出来,超时啊以下是同小组的代码,没有用线段树也过了,我还没有学习线段树,所以用模拟的方法#include#includeint b[100015];int main(){ intcount=1; int t; scanf(原创 2015-12-18 18:10:45 · 477 阅读 · 0 评论 -
HDOJ 2101 A + B Problem Too
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2101做难题太打击人了,想做做水题,结果让人纪念啊!!!!!!!!#include int main(){ inta,b; while(scanf("%d%d",&a,&b)!=EOF) printf("%s\n",(a+b)�==0?"yes":"no");原创 2015-12-18 18:11:02 · 1062 阅读 · 0 评论 -
HDOJ 1408 盐水的故事
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1408注意“假设最后一滴不到D毫升,则花费的时间也算一秒”这句话最后要检查是否加1,,,,#include int main(){ intt,n,i; doublev,d; while(scanf("%lf%lf",&v,&d)!=EOF) {原创 2015-12-18 18:11:05 · 402 阅读 · 0 评论 -
HDOJ 2030 汉字统计
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2030做这一道题只要知道汉字的机内码就可以了,汉字的ASCII码的首位是1,所以为负,.而且汉字是用两个字节编码的#include #include #include using namespace std;int main(){ char a[1000]; int i,k,p,n;原创 2015-12-18 18:11:08 · 535 阅读 · 0 评论 -
HDOJ 2031 进制转换
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2031除R取余数就可以,,,,#include using namespace std;int main(){ char c; int n,r,a,b[100],i,j; while(cin>>n>>r) { i=0; if(n>0) a=n; els原创 2015-12-18 18:11:10 · 367 阅读 · 0 评论 -
HDOJ 2032 杨辉三角
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2032打印杨辉三角,注意格式就好,比如空格,换行之类的#include #include int a[35][35];void inti(int n){ memset(a,0,sizeof(a)); a[1][1]=1; printf("1\n"); for(in原创 2015-12-18 18:11:12 · 411 阅读 · 0 评论 -
HDOJ 2033 人见人爱A+B
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2033时分秒相加,只要控制好进位就好,,,,#include int main(){ intn,ah,am,as,bh,bm,bs,h,m,s; scanf("%d",&n); while(n--) { h=m=s=0; scanf(原创 2015-12-18 18:11:15 · 584 阅读 · 0 评论 -
HDOJ 2034 人见人爱A-B
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2034#include#includeusing namespace std;int main(){ int n,m; while(cin>>n>>m&&!(n==0&&m==0)) { inti,j,k=0,a[101],b[101],c[101]={0}; for原创 2015-12-18 18:11:17 · 616 阅读 · 1 评论 -
HDOJ 2040 亲和数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2040稍稍优化一下,,,其实好像暴力过也可以,#include #include using namespace std;int main(){ intn,i,a,b,sa,sb; cin>>n; while(n--) { cin>>a>>b;原创 2015-12-18 18:11:20 · 499 阅读 · 0 评论 -
HDOJ 2501 Tiling_easy version
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2501找出递推关系是就好,f(n)=2*f(n-2)+f(n-1)因为前f(n-1)排好后后面只有2*1竖着一种排法前f(n-2)排好后两个有2*1/2*1(横和竖两种,其中竖着排与前面的f(n-1)的一种排法相同,所以这里只能算一种)和2*2(一种)共两种,,#include using n原创 2015-12-18 18:11:23 · 470 阅读 · 0 评论 -
HDOJ 2565 放大的X
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2565注意格式,每最后一个X后面再没有空格了#include using namespace std;int main(){ intn,s; cin>>n; while(n--) { cin>>s; for(int i=s;i>=s原创 2015-12-18 18:11:25 · 556 阅读 · 0 评论 -
HDOJ 1406 完数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1406有时候暴力,也是一种解决问题的方法....#include #include #define SWAP(X,Y) {int T;T=X;X=Y;Y=T;}bool judge(int n){ intj,sum=1; for(j=2;j { if(n原创 2015-12-18 18:11:27 · 650 阅读 · 0 评论 -
HDOJ 1210 Eddy's 洗牌问题
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1210思考方向:每个牌从离开原来位置到原来位置停止例如:11 22 43 84 35 6612 //2^n;711 //2^n-1;8 99 510 1011 712 1最后返回到原来位置停止,,,,#includeint main(){ int n,M原创 2015-12-18 18:11:30 · 542 阅读 · 0 评论 -
HDOJ 1407 测试你是否和LTC水平…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1407暴力求解,,,,,#include int main(){ intnum,x,y,z,l,m; while(scanf("%d",&num)!=EOF) { l=m=0; for(x=1;x*x {原创 2015-12-18 18:11:33 · 538 阅读 · 0 评论 -
HDOJ 2178 猜数字
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2178题目很很不清楚的一道水题,没有为什么这样,但这样就过了#include #include int main(){ intt,n; scanf("%d",&t); while(t--) scanf("%d",&n),printf("%d\n",(int原创 2015-12-18 18:11:35 · 570 阅读 · 0 评论 -
HDOJ 2519 新生晚会
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2519在计算的过程中注意精度的保存。。。。。#include int main(){ intt,n,m,i; doublesum; scanf("%d",&t); while(t--) { sum=1; scanf("%d%原创 2015-12-18 18:11:37 · 444 阅读 · 0 评论 -
HDOJ 2520 我是菜鸟,我怕谁
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2520#include int main(){ int t,n; scanf("%d",&t); while(t--) scanf("%d",&n),printf("%d\n",n*n000); return 0;}原创 2015-12-18 18:11:40 · 440 阅读 · 0 评论 -
HDOJ 2521 反素数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2521其实这一道题和反素数没有什么关系,,求出每个数的因子就可以,*****1的因子为1#include #include int inti(int n){ if(n==1) return 1; intsum=2,i; for(i=2;i原创 2015-12-18 18:11:42 · 859 阅读 · 0 评论 -
HDOJ 4311 Meeting point-1
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4311题解报告:平面上两点间的 Manhattan 距离为 |x1-x2| + |y1-y2| X 方向的距离与 Y 方向上的距离可以分开来处理。假设我们以 (xi,yi)作为开会的地点,那么其余的点到该开会地点所需的时间为 X 方向上到 xi 所需要的时间加上 Y 方向上到 yi 所需要的时间。原创 2015-12-18 18:11:47 · 418 阅读 · 0 评论 -
HDOJ 4312 Meeting point-2
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4312题解报告;平面上两点间的 Chebyshev距离为 max(|x1-x2|, |y1-y2|) 4312 Meeting point-2" TITLE="HDOJ 4312 Meeting point-2" />这和上一道题差不多求max(|x1-x2|, |y1-y2|)怎原创 2015-12-18 18:11:49 · 402 阅读 · 0 评论 -
HDOJ 2041 超级楼梯
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2041题目是一个递退题,用前两种状态,来表示现在的状态,,,关系式:f(n)=f(n-1)+f(n-2);#include int main(){ intn,t; inti,a[45]; a[0]=a[1]=1; for(i=2;i a[i]=a原创 2015-12-18 18:12:14 · 386 阅读 · 0 评论 -
HDOJ 2042 不容易系列之二
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2042习惯性,正着不好做倒着来做,倒着来想,,推到公式:f(n)=(f(n)-1)*2,,,,#include int main(){ intn,t; inti,a[30]; a[0]=4; for(i=1;i a[i]=(a[i-1]-1)*2原创 2015-12-18 18:12:17 · 489 阅读 · 0 评论 -
HDOJ 2044 一只小蜜蜂...
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2044题目告诉的从哪里走到哪里其实不重要,而是看你走了多少,__int64,菲波拉数列#include #include int main(){ intt,a,b; __int64p[51]={0,1,2,3}; scanf("%d",&t); while(t原创 2015-12-18 18:12:19 · 520 阅读 · 0 评论 -
HDOJ 2045 不容易系列之(3)—— L…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2045推导公式:f(n)=2*f(n-2)+f(n-1)因为假设前(n-2)个排好,剩下的就只有两种排法如果前(n-1)个排好,那么最后一个就只有一种排法数据可能很大要使用long long int 或(__int64)#includeint main (){ inti,a;原创 2015-12-18 18:12:22 · 455 阅读 · 0 评论 -
HDOJ 2046 骨牌铺方格
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2046推导公式:f(n)=f(n-2)+f(n-1)与2046题很相似,因为假设前(n-2)个排好,剩下的就只有两种排法如果前(n-1)个排好,那么最后一个就只有一种排法但(n-2)的和(n-1)的一种是相同的,所以要去掉一种#includeint main (){ inti,a;原创 2015-12-18 18:12:25 · 516 阅读 · 0 评论