广东工业大学2017新生赛(决赛)网络同步赛题解

Problem B: 狗哥的肚子

Time Limit: 1 Sec  Memory Limit: 128 MB

Description【http://gdutcode.sinaapp.com/problem.php?cid=1071&pid=1】

在 ACM 集训队中,狗哥的肚子形状多变,令人啧啧称奇,但是大家都有一个疑问,狗哥的肚子在最大的时候,能有多大呢?于是大家通过观察测量,用三种近似形状和相对应的整数数据来描述狗哥的肚子。
但是狗哥的肚子实在太多变化的形状了,大家没有办法找出其中最大的值,于是请求你写一个程序,来计算狗哥的肚子横截面的最大面积。

Input

第一行是一个正整数T,代表有T组输入。
每组输入第一行是一个整数 N ,表示狗哥的肚子形状变化个数。
接下来 N 行,每行开头包括一个大写字母,可能是 T (三角形)、 R (矩形) 、 C (圆形) ,表示狗哥肚子横截面的形状。
在字母后,是一到两个整数,表示形状的尺寸,也就是说T后会跟着两个整数,分别代表着三角形的底和高,,R后会跟着两个整数,代表着矩形的两条邻边的长度,而 C 后会跟着一个整数,代表着半径。
保证 N ≤ 1000 ,尺寸都在[0,100]之间,且定义 π = 3.14159。

Output

对于每一组样例,输出最大的狗哥的肚子横截面积,结果请保留两位小数。

Sample Input

2 1 T 3 2 4 T 3 2 R 2 1 C 5 C 10

Sample Output

3.00 314.16

HINT

第二个输入,选择 C 10 ,因为 10 × 10 × 3.14159 = 314.159(保留两位小数) = 314.16 。

【代码】:

#include <bits/stdc++.h>

using namespace std;
int t,n;
char a[5];
int d,h;
int c,k;
int r;
double s;
double ma=0;
#define PI 3.14159
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        ma=0;//注意内部置位!
        scanf("%d",&n);
        while(n--)
        {
            scanf("%s",a);
            if(a[0]=='T')
            {
                scanf("%d%d",&d,&h);
                s=(double)(d*h*1.0/2);
            }
            else if(a[0]=='R')
            {
                scanf("%d%d",&c,&k);
                s=(double)(c*k*1.0);
            }
            else
            {
                scanf("%d",&r);
                s=(double)(PI*r*r*1.0);
            }
            ma=max(ma,s);
        }
        printf("%.2f
",ma);
    }
    return 0;
}
模拟

Problem K: 这题有点难

Time Limit: 1 Sec  Memory Limit: 128 MB

Description

给你两个正整数a、 b。
现在有Q次询问,每次询问给出一个整数c,问是否存在正整数x,y可以使得
x * a - y * b == c

Input

第一行一个整数,表示样例组数T( 1 <= T <= 20 )
每组样例第一行三个整数 a、 b、 Q,其中(1 <= a,b <= 100, 1 <= Q <= 10000)
接下来 Q行,每行一个整数 c(-100 <= c <= 100)

Output

对于每个若可以满足方程,则输出"Yes"(没有引号),否则输出"No"(没有引号)

Sample Input

1 2 2 3 21 30 34

Sample Output

No Yes Yes

HINT

【分析】:c可以整除a和b的最大公因数就行了。拓展欧几里得。

【代码】:

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int mx,mx2,n,mn=-1e9,res;
int a[N];
int main()
{
    int t;
    int n,m,q;
    int a;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&n,&m,&q);
        int x=__gcd(n,m);
        while(q--)
        {
            scanf("%d",&a);
            if(a%x==0)
            {
                printf("Yes
");
            }
            else {
                printf("No
");
            }
        }
    }
    return 0;
}
View Code

 【同类】:http://acm.nyist.net/JudgeOnline/problem.php?pid=144

【详解】:https://www.cnblogs.com/hadilo/p/5914302.html  &&  https://www.cnblogs.com/frog112111/archive/2012/08/19/2646012.html


Problem J: csjhl和潮汕煎蚝烙

Time Limit: 1 Sec  Memory Limit: 128 MB

Description

csjhl为什么叫csjhl呢?因为他很喜欢吃潮汕煎蚝烙。可是黄小悦同学一直喜欢和csjhl抢着吃,于是他们决定用24点决一死战。可是他们都很饿,所以一致同意玩简单版的24点。一共有5张牌,牌上数字的范围是1到10,牌的顺序不可以改变,并且只能使用加法和减法。在24点上csjhl单挑无敌,在他看到牌的时候他已经在思考用哪一种方法赢了黄小悦同学。可是csjhl不会数数,所以请你来编写一个程序告诉他一共有多少种方法取得胜利。

Input

输入一个T,表示样例组数。
接下来T行,每行5个整数ai。(0<ai<11)

Output

输出csjhl可以取胜的方案数。

Sample Input

3 1 1 5 5 10 1 1 7 7 10 7 7 1 1 10

Sample Output

0 1 2

HINT

第二组有一种方案 1-1+7+7+10=24

第三组有两种方案 7+7-1+1+10=24 7+7+1-1+10=24

 【分析】:dfs 取+/- 

【代码】:

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
int ans;
void dfs(int sum,int cur)//
{
    if(cur>5)
    {
        if(sum==24)
        {
            ans++;
        }
            return ;
    }
    dfs(sum+a[cur],cur+1);
    dfs(sum-a[cur],cur+1);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        ans=0;
        for(int i=1;i<=5;i++)
        {
            scanf("%d",&a[i]);
        }
        dfs(a[1],2);
        printf("%d
",ans);
    }

    return 0;
}
View Code
原文地址:https://www.cnblogs.com/Roni-i/p/8022385.html