组队赛#2解题总结

比赛链接:click here~~

A BNU ACM校队时间安排,模拟自能

手速题:

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
    int t;
    scanf("%d", &t);
    while (t--)
    {
        int tmp;
        scanf("%d", &tmp);
        switch (tmp)
        {
        case 1:
            printf("Unknown\n");
            break;
        case 2:
        case 3:
            printf("Spring Training\n");
            break;
        case 4:
            printf("Spring Training\nBNU Contest\n");
            break;
        case 5:
        case 6:
            printf("Unknown\n");
            break;
        case 7:
            printf("Practice Week\nSummer Training\n");
            break;
        case 8:
            printf("Summer Training\n");
            break;
        case 9:
        case 10:
            printf("Regional Contest\n");
            break;
        case 11:
            printf("Basic Training\nRegional Contest\n");
            break;
        case 12:
            printf("Basic Training\nRookie Contest\n");
            break;
        }
    }
    return 0;
}

B 沙漠之旅

应该是多重背包,当时没想那么多,用模拟过的。

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
int i,j,L,X,N;
bool flag;
int a[1005];
int aa[2100];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&L,&X,&N);
        for(int i=0; i<N; i++)
        {
            scanf("%d",&a[i]);
        }
        memset(aa,0,sizeof(aa));
        int ANS;
        for(int i=0; i<N; i++)//n^2复杂度处理两两组合
        {
            for(int j=0; j<N; j++)
            {
                ANS=a[i]+a[j];//4 5 5 6
                //cout<<ANS<<endl;
                aa[ANS]=1;
            }
        }
        bool flag=0;
        int t=L-X;//11
        for(int i=1; i<t; i++)
        {
            if(aa[i]&&aa[t-i])//满足条件则跳出
            {
                puts("Yes");
                flag=1;
                break;
            }
        }
        if(flag==0)
            puts("No");
    }
    return 0;
}

C. Adidas vs Adivon

【解题思路】:

判断一下,在不断的对半切的过程中一直 /2,直到是一个奇数或者为0.统计次数。长和宽的次数相加。判断奇偶性就可以了。

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
int i,j,L,X,N;
bool flag;
int a[1005];
int aa[2100];
int main()
{
    int t,m,n;
    cin>>t;
    while(t--)
    {
        int sum=0;
        scanf("%d%d",&m,&n);
        while(m%2==0)
        {
            m=m/2;
            sum++;
        }
        while(n%2==0)
        {
            n=n/2;
            sum++;
        }
        if(sum%2!=0)
            printf("Adidas loses\n");
        else
            printf("Adivon prevails\n");
    }
    return 0;
}

F. Taiko taiko

【解题思路】一种情况是Y。一种情况是N,是Y的话,递推加1,是N的话,没分,a1=(a1+1)*p;b1+=a1;累加即可

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <string.h>
#include <algorithm>
using namespace std;
int i,j,L,X,N;
bool flag;
int a[1005];
int aa[2100];
int main()
{
    int t,n,m,i,j;
    double a1,b1,p;
    scanf("%d",&t);
    while(t--)
    {
        a1=b1=0;
        scanf("%d%lf",&n,&p);
        for(i=1;i<=n;i++){
            a1=(a1+1)*p;
            b1+=a1;
        }
        printf("%.6lf\n",b1);
    }
    return 0;
}

H. 硬币水题II

概率,,不解释。。

#include <stdio.h>
#include <string.h>
int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        double n;
        scanf("%lf", &n);
        printf("%.2lf\n", 1/(n * (1 - n)));
    }
    return 0;
}

J. 鸣人的查克拉

【解题思路】:很有意思的一道题,简直考智商!

我的思路:最多发动2次,然后输入一个数,每次更新一下前一次的最大值,具体见代码了

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <string.h>
#include <algorithm>
using namespace std;
int Minn=-0x3f3f3f3f;
int main()
{
    int i,j,c,x,n,m;
    int a1,a2,a3,a4,a5;
    cin>>c>>n;
    a1=c;
    a2=a3=a4=a5=Minn;
    for(i=1; i<=n; i++)
    {
        cin>>x;
        if(a1>=x)
            a2=max(a2,a1-x); //9-9-9-9-9     /*第一步找消耗最小的,即剩余最大*/
        a3=max(a3,a2+x);     //10-11-12-12-14    /*第二步找下一次发动(也就是第一次发动)能增加最多的*/
        if(a3>=x)
            a4=max(a4,a3-x); //9-9-9-10-10   /*第三步找第二次发动消耗的最小的,剩余最大的
        a5=max(a5,a4+x);     //10-11-12-12-15   /*最后找最大的!*/
    }
    int res1=max(a3,a5);     //11-12-12-15
    int res2=max(a1,res1);   //11-12-12-15
    cout<<res2<<endl;//15!
}
/*
1  10-9  发动,变为9
2  9     不发动,9
3  12    结束1的时刻,加3 变为12
2  12-10 发动,为10
5  15    结束,加5为15!
*/

L斩

【解题思路】:

求直线与矩形交分割面积最小的那块面积的大小,计算几何,,共六种情况:

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n,x1,y1,xr,yr,a,b,c;
    cin>>n;
    while(n--)
    {
        cin>>x1>>y1>>xr>>yr>>a>>b>>c;
        double s,S;
        double xy0=(c+b*y1)*1.0/-a;  //上下交,求出下交点
        double xy1=(c+b*yr)*1.0/-a;  //上下交,求出上交点
        double yx0=(c+a*x1)*1.0/-b;  //左右交,求出左交点
        double yx1=(c+a*xr)*1.0/-b;  //左右交,求出右交点
        bool t1=(xy0>=x1)&&(xy0<=xr);//判断边界,在下方
        bool t2=(xy1>=x1)&&(xy1<=xr);//判断边界,在上方
        bool t3=(yx0>=y1)&&(yx0<=yr);//判断边界,在左方
        bool t4=(yx1>=y1)&&(yx1<=yr);//判断边界,在右方
        if(t1&&t2)                   //直线在上下交
            s=(xy1+xy0-2*x1)*(yr-y1)/2.0;//梯形面积,
        else if(t3&&t4)             //直线在左右交
            s=(yx0+yx1-2*y1)*(xr-x1)/2.0;
        else if(t1&&t3)
            s=(yx0-y1)*(xy0-x1)/2.0;//三角形面积,
        else if(t1&&t4)
            s=(yx1-y1)*(xr-xy0)/2.0;
        else if(t2&&t3)
            s=(yr-yx0)*(xy1-x1)/2.0;
        else if(t2&&t4)
            s=(xr-xy1)*(yr-yx1)/2.0;
        S=fabs(xr-x1)*(yr-y1);
        s=min(s,S-s);
        printf("%.3lf\n",s);
    }
    return 0;
}
时间: 2024-08-09 10:27:37

组队赛#2解题总结的相关文章

组队赛#1 解题总结 ZOJ 3803 YY&#39;s Minions (DFS搜索+模拟)

YY's Minions Time Limit: 2 Seconds      Memory Limit: 65536 KB Despite YY's so much homework, she would like to take some time to play with her minions first. YY lines her minions up to an N*M matrix. Every minion has two statuses: awake or asleep. W

组队赛#1 解题总结 ZOJ 3798 Abs Problem (找规律+打表)

Abs Problem Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Alice and Bob is playing a game, and this time the game is all about the absolute value! Alice has N different positive integers, and each number is not greater than N.

CUGBACM_Summer_Tranning 组队赛解题报告

组队赛解题报告: CUGBACM_Summer_Tranning 5:组队赛第五场 CUGBACM_Summer_Tranning 4: CUGBACM_Summer_Tranning 3:组队赛第三场 CUGBACM_Summer_Tranning 2:组队赛第二场 CUGBACM_Summer_Tranning 1:组队赛第一场 CUGBACM_Summer_Tranning 组队赛解题报告

解题报告 之 POJ3057 Evacuation

解题报告 之 POJ3057 Evacuation Description Fires can be disastrous, especially when a fire breaks out in a room that is completely filled with people. Rooms usually have a couple of exits and emergency exits, but with everyone rushing out at the same time

LeetCode Plus One Java版解题报告

https://oj.leetcode.com/problems/plus-one/ 题意:一个整数按位存储于一个int数组中,排列顺序为:最高位在array[0] ,最低位在[n-1],例如:98,存储为:array[0]=9; array[1]=8; 解题思路,从数组的最后一位开始加1,需要考虑进位,如果到[0]位之后仍然有进位存在,需要新开一个长度为(n.length + 1)的数组,拷贝原来的数组. public class Solution { public int[] plusOne

SICP 习题 (1.46)解题总结

SICP 习题 1.46 要求我们写一个过程iterative-improve,它以两个过程为参数,其中一个参数用来检测猜测是否足够好,另一个参数用来改进猜测.过程iterative-improve应该返回另一个过程,所返回的过程接收一个参数作为初始猜测,然后不断改进猜测直到结果足够好.题目还要求我们使用iterative-improve重写1.1.7的sqrt过程和1.3.3节的fixed-point过程. 因为涉及到高阶函数,所以整个题目理解起来有一点点费劲.不过这道题作为第一章的收官题确实

关于解题的思路与方法

很多学生问我这个问题,拿来一道题(或实际一个问题)解决它的思路和方法是什么. 其实人的思维是最难描述的.每个人的思考方式和习惯都不尽相同,解决同一个问题达到同一个效果的方式也是如此.简单的讲,"思路"是难以给出一个单一模式的,但是前人还是总结了很多方法.下面列出我个人比较常用的解题方法和思路,供大家参考. 博文首发地址:http://blog.csdn.net/duzixi 先说说解体思路. 解体思路有两大基本套路:一个是"自上而下",另一个是"自下而上&

hdu 1541 Stars 解题报告

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1541 题目意思:有 N 颗星星,每颗星星都有各自的等级.给出每颗星星的坐标(x, y),它的等级由所有比它低层(或者同层)的或者在它左手边的星星数决定.计算出每个等级(0 ~ n-1)的星星各有多少颗. 我只能说,题目换了一下就不会变通了,泪~~~~ 星星的分布是不是很像树状数组呢~~~没错,就是树状数组题来滴! 按照题目输入,当前星星与后面的星星没有关系.所以只要把 x 之前的横坐标加起来就可以了

【百度之星2014~初赛(第二轮)解题报告】Chess

声明 笔者最近意外的发现 笔者的个人网站http://tiankonguse.com/ 的很多文章被其它网站转载,但是转载时未声明文章来源或参考自 http://tiankonguse.com/ 网站,因此,笔者添加此条声明. 郑重声明:这篇记录<[百度之星2014~初赛(第二轮)解题报告]Chess>转载自 http://tiankonguse.com/ 的这条记录:http://tiankonguse.com/record/record.php?id=667 前言 最近要毕业了,有半年没做