码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-03-02 00:15:34      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:section   put   names   控制台   int   mon   答案   ons   namespace   

官方题解:http://www.cnblogs.com/qscqesze/p/6480284.html

哗啦啦村的刁难(1)

哗啦啦村作为喵哈哈村的对头,于是他们准备给喵哈哈村一个好看。

哗啦啦村的头号长老——鱼先生,就提出了以下问题:

给你三个木棍,问你这三个木棍,是否能够组成一个非退化的三角形!

第一行一个整数T,表示测试组数的个数。
接下来T行,每行三个整数,a,b,c。表示哗啦啦村提供的三根木棍。

满足
1<=T<=100
1<=a,b,c<=5000

如果可以组成三角形,那就输出Yes,否则输出N

 复制
2
1 1 1
1 1 10
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秒时,机器人的坐标。

 复制
NSWWNSNEEWN
12
-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
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.
保留整数即可。

 复制
4
1 5 3 4
6
解法:n中取三个数,判断是不是三角形,再根据海伦公式计算面积
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 #include <math.h>
 5 #include <iostream>   // C++头文件,C++完全兼容C
 6 #include <algorithm>  // C++头文件,C++完全兼容C
 7 #include <time.h>
 8 #define fre  freopen("in.txt","r",stdin)   //以文件代替控制台输入,比赛时很常用,能缩短输入测试样例的时间
 9 #define INF 0x3f3f3f3f
10 #define inf 1e60
11 using namespace std;  // C++头文件,C++完全兼容C
12 const int maxn = 200;
13 int a[maxn];
14 int b[3];
15 int ans,n,k;
16 double s=0.0;
17 int flag=0;
18 void dfs(int cur,int cnt,double num)
19 {
20     if(cnt==3)
21     {
22         sort(b,b+3);
23         if(b[0]+b[1]>b[2])
24         {
25            flag=1;
26            s=max(s,(double)sqrt(num/2*(num/2-b[0])*(num/2-b[1])*(num/2-b[2])));
27         }
28         return ;
29     }
30     for(int i=cur; i<n; i++)
31     {
32         b[cnt]=a[i];
33         dfs(i+1,cnt+1,num+a[i]);
34     }
35 }
36 int main()
37 {
38     scanf("%d",&n);
39     for(int i=0; i<n; i++)  scanf("%d",&a[i]);
40     sort(a,a+n);
41     dfs(1,0,0.0);
42    // cout<<flag<<endl;
43     if(flag)
44     {
45 
46         printf("%.0f\n",(s));
47     }
48     else
49     {
50         cout<<"-1"<<endl;
51     }
52     return 0;
53 }

哗啦啦村的刁难(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

输出答案

 复制
4 of week 
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;
}

 



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

标签:section   put   names   控制台   int   mon   答案   ons   namespace   

原文地址:http://www.cnblogs.com/yinghualuowu/p/6487022.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!