ACM ICPC WORLD FINAL

解法:排序大家都知道,去重的话,初学者用数组就好了

#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int a,b,c[100],i,d[31];
cin>>a;
while(a>0)
{
cin>>b;
for(i=0;i<31;i++)
d[i]=0;
for(i=0;i<b;i++)
{
cin>>c[i];
}
for(i=0;i<b;i++)
{
d[c[i]]++;
}
for(i=0;i<31;i++)
{
if(d[i]!=0)
cout<<i<<" ";
}
cout<<endl;
a--;
}
} 

解法:找规律,前面的n行都是在中间输出*,第n+1行全部输出*,接下来的以中间为对称关系,往两边扩展

#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n&&n)
{
for(int i=1;i<=2*n+1;i++)
{
for(int j=1;j<=2*n+1;j++)
{
if(j==n+1)
{
cout<<"*";
}
else if(i==n+1)
{
cout<<"*";
}
else if(i>n+1)
{
int pos=i-(n+1);
//cout<<pos<<endl;
if(n+1-pos==j||n+1+pos==j)
{
cout<<"*";
}
else
{
cout<<".";
}
}
else
{
cout<<".";
}
}
cout<<endl;
}
}
return 0;
}

我们都是江理人

解法:字符串处理(根据题意)

#include<stdio.h>
int main()
{
int n,t,i;
char a[1000];
scanf("%d",&n);
getchar();
while(n--)
{
i=0;
gets(a);
for(t=0;a[t]!='\0';t++)
{
if(a[t]=='1')
printf("love jiangli\n");
if(a[t]=='2')
printf("love xingong\n");
}
}
return 0;
}

回文素数

解法:数据不大,当然是先判断是不是回文再判断素数,(这里可以把数字一位一位分解倒着相加看是否相等)

#include<stdio.h>
int main()
{
int m,n,c,b,k,p,q,r;
while(scanf("%d%d",&m,&n)!=EOF)
{
if(m==0&&n==0)
break;
r=0;
for(k=m; k>=m&&k<=n; k++)
{
b=0;
p=k;
while(k>0)
{
c=k%10;
b=b*10+c;
k=k/10;
}
if(b==p)
{
for(q=2; q<p; q++)
if(p%q==0)
break;
if(q==p)
{
r=r+1;
}
}
k=p;
}
printf("%d\n",r);
}
}

兽兽扔铅球

解法:数学题,没什么好说的

#include <stdio.h>
#include<math.h>
int main()
{
int n;
float h,a,l;
while(scanf("%d",&n)!=EOF)
{
while(n--)
{
scanf("%f%f",&h,&a);
l=h/tan(a);
printf("%.3f\n",l);
}
}
return 0;
}  

魔兽争霸

解法:应该是计算斜率了(y2-y1)*(x3-x1)==(y3-y1)*(x2-x1)

#include<stdio.h>
int main()
{
double x1,x2,x3,y1,y2,y3;
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
{
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
if((y2-y1)*(x3-x1)==(y3-y1)*(x2-x1)&&(x2-x1)*(x2-x1)>=(x3-x1)*(x3-x1)&&(y2-y1)*(y2-y1)>=(y3-y1)*(y3-y1))
printf("yes\n");
else printf("no\n");
}
}
return 0;
}

  

2013年江西理工大学C语言程序设计竞赛(初级组)的更多相关文章

  1. 2018年江西理工大学C语言程序设计竞赛(初级组)一

     C语言竞赛初级组第一.二场答案:https://www.cnblogs.com/xingkongyihao/p/10046918.html  A: 逆序对 时间限制: 1 s      内存限制:  ...

  2. 2017年江西理工大学C语言程序设计竞赛(初级组)

    问题 A: Petr的盒子(初) #include <iostream> #include <stdio.h> #include <algorithm> using ...

  3. 2013年江西理工大学C语言程序设计竞赛(高级组)

    A 解法:dfs搜索,注意一个剪枝,否则会超时(听说原本是个dp)? #include<stdio.h> //#include<bits/stdc++.h> #include& ...

  4. 2014江西理工大学C语言程序设计竞赛高级组题解

    1001 Beautiful Palindrome Number 枚举回文数字前半部分,然后判断该数字是否满足,复杂度为O(sqrt(n))! 1002 Recovery Sequence  本题的核 ...

  5. 2017年江西理工大学C语言程序设计竞赛(高级组)

    问题 A: 求近似值 #include <stdio.h> #include <time.h> #include <stdlib.h> using namespac ...

  6. 2018年江西理工大学C语言程序设计竞赛(高级组) 三角平方数

    题目描述 三角数:形如图a,圆点摆放成等边三角形的数字,则为三角数. (图a) 平方数:形如图b,小方块摆放成正方形的数字,则为平方数. (图b) 那么如果一个数字既是三角形数又是平方数,则称为三角平 ...

  7. 2018年江西理工大学C语言程序设计竞赛高级组部分题解

    B Interesting paths 考察范围:组合数学 此题是机器人走方格的变种,n*m的网格,从(1,1)走到(n,m),首先可以明确,水平要走m-1格,竖直要走n-1格,则走到目的地的任意一条 ...

  8. 2014江西理工大学C语言程序竞赛初级组

    坐公交 解法:略 #include<stdio.h> #include<string> #include<iostream> #include<math.h& ...

  9. 2016年江西理工大学C语言程序设计竞赛(高级组)

    问题 A: jxust 解法:争议的问题(是输入整行还是输入字符串),这里倾向输入字符串,然后判断是否含有jxust就行 #include<bits/stdc++.h> using nam ...

随机推荐

  1. java异常类

    package shb.java.exception; /** * 测试异常类 * @Package:shb.java.exception * @Description: * @author shao ...

  2. 刚刚学了循环,1到n的求和与阶乘

    //求和 int a = Convert.ToInt32(Console.ReadLine()); int c = 0; for (int b = 0; b <= a; b++) { c = c ...

  3. windows下pip升级到8.1.2

    升级pip只要切换到easy_install-3.5目录下:  easy_install-3.5 pip==8.1.2

  4. 出现“不能执行已释放的Script代码”错误的原因及解决办法

    很多web开发者或许都遇到过这样的问题,程序莫名奇怪出现“不能执行已释放Script的代码”,错误行1,列1.对于这种消息描述不着边,行列描述更是让人迷茫的js错误,相信是所有调试js程序的朋友们最郁 ...

  5. TVideoGrabber如何并行处理多摄像头

    大家都知道 TVideoGrabber是一款支持包括C#..NET.VB.NET.C++.Delphi.C++Builder和ActiveX平台在内的视频处理控件,可以捕捉视频,也可以作为多媒体播放器 ...

  6. ServiceStack.Redis之IRedisClient 03_转

    事实上,IRedisClient里面的很多方法,其实就是Redis的命令名.只要对Redis的命令熟悉一点就能够非常快速地理解和掌握这些方法,趁着现在对Redis不是特别了解,我也对着命令来了解一下这 ...

  7. 【Pro ASP.NET MVC 3 Framework】.学习笔记.10.SportsStore:上传图片

    1 扩展数据库 打开表定义,新增两列可空 ) 2 增强领域模型 为Products类添加如下属性 publicstring ImageMimeType { get; set; } 第一个属性不会在界面 ...

  8. A Mysql backup script

    UseCentOS can help IT managers to get rid of the boring learning methods, quick grasp Linux technolo ...

  9. php获取目录中的所有文件名

    <?php /** * [php获取目录中的所有文件名] */ //1.先打开要操作的目录,并用一个变量指向它 //打开当前目录下的目录pic下的子目录common. $handler = op ...

  10. 30、springmvc

    第一章回顾JavaWeb中的MVC设计模式 1)MVC这种设计模式,不光运用于Web领域,而且也能用于非Web领域 2)今天说的MVC特指一种表现层设计模式,不限于Java语言 第二章回顾struts ...