您的位置:首页 > 其它

喵哈哈村的魔法考试 Round #3 (Div.2) ABCDE

2017-03-01 23:43 330 查看
官方题解:http://www.cnblogs.com/qscqesze/p/6480284.html

哗啦啦村的刁难(1)

描述哗啦啦村作为喵哈哈村的对头,于是他们准备给喵哈哈村一个好看。哗啦啦村的头号长老——鱼先生,就提出了以下问题:给你三个木棍,问你这三个木棍,是否能够组成一个非退化的三角形!输入
第一行一个整数T,表示测试组数的个数。
接下来T行,每行三个整数,a,b,c。表示哗啦啦村提供的三根木棍。满足
1<=T<=100
1<=a,b,c<=5000输出
如果可以组成三角形,那就输出Yes,否则输出N样例输入1 复制
2
1 1 1
1 1 10
样例输出1
Yes
No
解法:就是那么判断三角形
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>   // C++头文件,C++完全兼容C
#include <algorithm>  // C++头文件,C++完全兼容C
#include <time.h>
#define fre  freopen("in.txt","r",stdin)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
#define INF 0x3f3f3f3f
#define inf 1e60
using namespace std;  // C++头文件,C++完全兼容C
int i,j;
int n,m;
int sum,ans,flag;
int t;
int main()
{
int a[3];
int t;
cin>>t;
while(t--)
{
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
if((a[1]+a[0])>a[2])
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
return 0;
}

哗啦啦村的刁难(2)

描述哗啦啦村作为喵哈哈村的对头,于是他们准备给喵哈哈村一个好看。哗啦啦村的二号长老——咸先生,就提出了以下问题:咸先生提供了一个机器人。这个机器人可以按照输入的命令进行移动,命令包括‘E’、‘S’、‘W’、‘N’四种,分别对应东南西北。执行某个命令时,它会向对应方向移动一个单位。作为新型机器人,它可以执行命令串。对于输入的命令串,每一秒它会按命令行动一次。执行完命令串的最后一个命令后,会自动从头开始循环。在0时刻时机器人位于(0,0)。求T秒后机器人所在位置坐标。输入
第1行:一个字符串,表示早苗输入的命令串,保证至少有1个命令
第2行:一个正整数T
T<=2,000,000,000 且命令串长度<=5,000输出
2个整数,表示T秒时,机器人的坐标。样例输入1 复制
NSWWNSNEEWN
12
样例输出1
-1 3
解法:暴力是超时(试过了),我们取模再加上重复执行的次数就可以了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>   // C++头文件,C++完全兼容C
#include <algorithm>  // C++头文件,C++完全兼容C
#include <time.h>
#define fre  freopen("in.txt","r",stdin)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
#define INF 0x3f3f3f3f
#define inf 1e60
using namespace std;  // C++头文件,C++完全兼容C
int i,j;
int n,m;
int sum,ans,flag;
int t;
int main()
{
string s;
int n;
int x=0;
int y=0;
int num=0;
int i=0;
cin>>s>>n;
int l=s.length();
int ans=n%l;
int pos=n/l;
//cout<<ans<<endl;
while(i<l)
{
if(s[i]=='E')
{
x++;
}
else if(s[i]=='W')
{
x--;
}
else if(s[i]=='N')
{
y++;
}
else
{
y--;
}
i++;
}
x=x*pos;
y=y*pos;
i=0;
while(i<ans)
{
if(s[i]=='E')
{
x++;
}
else if(s[i]=='W')
{
x--;
}
else if(s[i]=='N')
{
y++;
}
else
{
y--;
}
i++;
}
cout<<x<<" "<<y<<endl;
return 0;
}

哗啦啦村的刁难(3)

描述哗啦啦村作为喵哈哈村的对头,于是他们准备给喵哈哈村一个好看。哗啦啦村的三号长老——大先生,就提出了以下问题:现在这道题有两组数据,每组输入数据都是1,。但是,第一组测试数据你需要输出1,第二组你需要输出2。你怎么输出呢?输入
1输出
这道题只包含两组测试数据,第一组测试数据应该输出1,第二组你应该输出2.样例输入1 复制
1
样例输出1
1
样例输入2 复制
1
样例输出2
2
解法:卿学姐说OJ是并行哒,所以时间随机是不可行的,我们这里new一个东西,取地址是随机的
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>   // C++头文件,C++完全兼容C
#include <algorithm>  // C++头文件,C++完全兼容C
#include <time.h>
#define fre  freopen("in.txt","r",stdin)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
#define INF 0x3f3f3f3f
#define inf 1e60
using namespace std;  // C++头文件,C++完全兼容C
const int maxn = 200;
int a[maxn];
int b[3];
int ans,n,k;

int main()
{

cin>>n;
char* x=new char;
int ans=(long)x;
printf("%d\n",ans/10%2+1);

return 0;
}

哗啦啦村的刁难(4)

描述哗啦啦村作为喵哈哈村的对头,于是他们准备给喵哈哈村一个好看。哗啦啦村的四长老——四先生,就提出了以下问题:给你n条边,让你从里面选出三条边,组成一个三角形,问你这个三角形最大的面积可以为多少?如果无论如何都不能组成三角形,输出-1。输入
第1行:一个整数n,表示边的个数。
第2行,n个整数,表示每条边的边长。
1<=n<=100 1<=a[i]<=100输出
输出最大面积,无解输出-1.
保留整数即可。样例输入1 复制
4
1 5 3 4
样例输出1
6
解法:n中取三个数,判断是不是三角形,再根据海伦公式计算面积
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>   // C++头文件,C++完全兼容C
#include <algorithm>  // C++头文件,C++完全兼容C
#include <time.h>
#define fre  freopen("in.txt","r",stdin)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
#define INF 0x3f3f3f3f
#define inf 1e60
using namespace std;  // C++头文件,C++完全兼容C
const int maxn = 200;
int a[maxn];
int b[3];
int ans,n,k;
double s=0.0;
int flag=0;
void dfs(int cur,int cnt,double num)
{
if(cnt==3)
{
sort(b,b+3);
if(b[0]+b[1]>b[2])
{
flag=1;
s=max(s,(double)sqrt(num/2*(num/2-b[0])*(num/2-b[1])*(num/2-b[2])));
}
return ;
}
for(int i=cur; i<n; i++)
{
b[cnt]=a[i];
dfs(i+1,cnt+1,num+a[i]);
}
}
int main()
{
scanf("%d",&n);
for(int i=0; i<n; i++)  scanf("%d",&a[i]);
sort(a,a+n);
dfs(1,0,0.0);
// cout<<flag<<endl;
if(flag)
{

printf("%.0f\n",(s));
}
else
{
cout<<"-1"<<endl;
}
return 0;
}

哗啦啦村的刁难(5)

描述哗啦啦村作为喵哈哈村的对头,于是他们准备给喵哈哈村一个好看。哗啦啦村的五号长老——巫先生,就提出了以下问题:一是想知道2016年中,周X有多少天。二是想知道2016年中,每个月的X号一共有多少天。请你帮帮他回复吧!输入
x of week:表示小明想知道2016年周x有多少天
x of month:表示小明想知道2016年x号有多少天
两个单词之间只会有一个空格。
X of week 中 的x:1<=x<=7
X of month中的x:1<=x<=31输出
输出答案样例输入1 复制
4 of week
样例输出1
52
解法:cfgoodbye2015A题,数日历
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>   // C++头文件,C++完全兼容C
#include <algorithm>  // C++头文件,C++完全兼容C
#define fre  freopen("in.txt","r",stdin)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
#define INF 0x3f3f3f3f
#define inf 1e60
using namespace std;  // C++头文件,C++完全兼容C
int i,j;
int n,m;
int sum,ans,flag;
int t;
int main()
{
char s[10000];
string s1="";
string s2="";
string s3="";
gets(s);
for(i=0;i<strlen(s);i++)
{
if(s[i]>='0'&&s[i]<='9')
{
s1+=s[i];
}
if(s[i]=='w')
{
s2+=s[i];
}
else if(s[i]=='m')
{
s2+=s[i];
}
}
if(s2[0]=='w')
{
if(s1=="5"||s1=="6")
{
puts("53");
}
else if(s1=="1"||s1=="2"||s1=="3"||s1=="4"||s1=="7")
{
puts("52");
}
}
else if(s2[0]=='m')
{
if(s1=="30")
{
puts("11");
}
else if(s1=="31")
{
puts("7");
}
else
{
puts("12");
}
}
return 0;
}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: