2015.4 校赛回顾

用了一下午时间重刷了一次校赛题目

不参考资料做的还是2333

第一题手速题

第二题

一开始取余运算少加了一个,WA了一发

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int i,d[20000];
    string c;
    memset(d,0,sizeof(d));
    while(cin>>c)
    {
        int n=0;
        for(i=0;i<8;i++)
        {
            n=(n+((int(c[i])-48)*(20-i))%100000)%100000;
        }
        d[n]=d[n]+1;
        cout<<d[n]<<endl;
    }
    return 0;
}

第三题

NOIP2014复赛题改编

硬做

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    int l,mi,i,j;
    long ii,jj;
    double x,y,shit,google,good,minus;
    while(cin>>x>>y>>l)
    {
        if(x==y){cout<<"1 1"<<endl;continue;}
        if(x>y){
            good=l;
            shit=x/y;
            //cout<<shit<<endl;
            for(i=l;i>l/2-1;i--)
            {
                for(j=i;j>=1;j--)
                {
                    google=(double)i/(double)j;
                    minus=google-shit;
                    //cout<<"->"<<" i:"<<i<<" j:"<<j<<" i/j:"<<google<<" -:"<<minus<<endl;
                    if(minus<0) continue;
                    if(minus<good) {good=minus;ii=i;jj=j;}
                }
            }
            mi=gcd(ii,jj);
            cout<<ii/mi<<" "<<jj/mi<<endl;
        }
        if(x<y){
            good=l;
            shit=x/y;
            //cout<<shit<<endl;
            for(i=1;i<l/2+1;i++)
            {
                for(j=i;j<=l;j++)
                {
                    google=(double)i/(double)j;
                    minus=google-shit;
                    //cout<<"->"<<" i:"<<i<<" j:"<<j<<" i/j:"<<google<<" -:"<<minus<<endl;
                    if(minus<0) continue;
                    if(minus<good) {good=minus;ii=i;jj=j;}
                }
            }
            mi=gcd(ii,jj);
            cout<<ii/mi<<" "<<jj/mi<<endl;
        }
    }
    return 0;
}

第四题

没做出,先占位

第五题

NOIP题目,最烦这种数学题,

不知道结论打死也做不出来

黄金分割((sqrt(5)-1)/2)*(n+1)

#include<cstdio>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int f[10];
int main()
{
    double a=(sqrt(5.0)-1.0)/2.0;
    long long d;
    f[0]=0;
    f[1]=1;
    f[2]=1;
    f[3]=2;
    f[4]=3;
    f[5]=3;
    f[6]=4;
    f[7]=4;
    while(~scanf("%lld",&d))
    {
        if(d<=7){cout<<f[d]<<endl;}
        else{
            cout<<(long long)(a*(d+1))<<endl;
        }
    }
    return 0;
}

第六题

最小生成树

一开始打算拍模板,书上的kru-代码没打全不能用

用了前面用过的模板T掉,换做prim,书上的代码WA

前后交了十几次也是醉了

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

struct Kruskal
{
    int x;
    int y;
    double value;
};

int father[100002], son[100002];

bool cmp(const Kruskal &a, const Kruskal& b)
{
    return a.value < b.value;
}

int unionsearch(int x)
{
    if (x == father[x])
        return x;
    else
        return unionsearch(father[x]);}

bool join(int x, int y)
{
    int root1 = unionsearch(x);
    int root2 = unionsearch(y);
    if (root1 == root2)
        return false;
    if (son[root1] >= son[root2])
    {
        father[root2] = root1;
        son[root1] +=son[root2];
    }
    else
    {
        father[root1] = root2;
        son[root2] += son[root1];
    }
    return true;
}

int main()
{

    double total = 0;
    double sum = 0;
    int n, m, flag = 0, num = 0;
    Kruskal edge[100002];
    scanf("%lf", &total);
    scanf("%d", &n);
    m = 1;
    while(3 == scanf("%d%d%lf", &edge[m].x, &edge[m].y, &edge[m].value))
        m++;
    m--;
    for(int i = 1; i <= n; i++)
    {
        father[i] = i;
        son[i] = 1;
    }
    sort(edge+1, edge+m+1, cmp);
    for (int i = 1; i <= m; i++)
    {
        if(join(edge[i].x, edge[i].y))
        {
            num++;  //edge number
            sum += edge[i].value;
        }
        if(num == n-1)
        {
            flag = 1;
            break;
        }
    }
    if (sum > total)
        flag = 0;
    if (flag)
        printf("Need %.2lf miles of cable\n", sum);
    else
        printf("Impossible\n");

    fclose(stdin);
    return 0;
}

第七题

还没看,占位

时间: 2024-07-29 06:29:49

2015.4 校赛回顾的相关文章

2015 GDUT校赛

周末打了个GDUT的校赛,也是作为SCAU的一场个人排位. 比赛中竟然卡了个特判,1个半钟就切了5条了,然后一直卡. 还有其他两条可以做的题也没法做了,性格太执着对ACM来说也是错呀. 讲回正题 . A  游戏王 . 目的是集齐6张卡, 然后n个小伙伴手上持有卡num, 给出m种集合 , Stubird需要有某个集合中的卡片才能用c的花费去买这张卡片. 做法是状压dp , 开一个 dp[st] , 表示st( 0 <= st < (1<<6) ) 这个集合最小花费 . 然后开一个邻

2015 多校赛 第一场 1007 (hdu 5294)

总算今天静下心来学算法.. Description Innocent Wu follows Dumb Zhang into a ancient tomb. Innocent Wu’s at the entrance of the tomb while Dumb Zhang’s at the end of it. The tomb is made up of many chambers, the total number is N. And there are M channels connect

2015 多校赛 第五场 1010 (hdu 5352)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5352 看题看得心好累. 题目大意: 给出 n 个点,依次执行 m 次操作:输入“1 x”时,表示将与 x 连通的点全部修复:输入“2 x y”,表示在 x 与 y 之间加一条边:输入“3 x y”,表示删除 x 与 y 之间的边.题目确保不会与重边并且操作合法. 题目会给出 k,要求每次修复的的点的数目小于等于k. 问:怎样执行操作1,使得令修复点数最多的同时,令每次执行操作1所修复的点的数目所构成

2015 多校赛 第四场 1010 (hdu 5336)

Problem Description XYZ is playing an interesting game called "drops". It is played on a r∗c grid. Each grid cell is either empty, or occupied by a waterdrop. Each waterdrop has a property "size". The waterdrop cracks when its size is

2015 多校赛 1002 (hdu 5289)

Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task to some staffs who were in the same group. In a group, the

2015 whu校赛f题big data(dp + 小技巧)

题意是给定五个数n(n <= 100),a,b,l,r 另外有函数序列f(x),其中f(x + 1) = f(x) + a或f(x)+ b,f(0) = 0,问有多少个这样的函数序列f(1)到f(n)使得函数序列的和在l和r之间 解题思路如下: 图片有一处错误,要减去的是a*(n + 1) * n而不是 (b - a)* (n + 1) * n,此外,要注意x/c时向上取整和向下取整的问题. 这道题做做停停一个月了今天终于找时间ac了,有点感人呐 代码如下: #include<cstdio&g

2015 多校赛 第四场 1009 (hdu 5335)

Problem Description In an n∗m maze, the right-bottom corner is the exit (position (n,m) is the exit). In every position of this maze, there is either a 0 or a 1 written on it. An explorer gets lost in this grid. His position now is (1,1), and he want

2015 多校赛 第二场 1006 (hdu 5305)

Problem Description There are n people and m pairs of friends. For every pair of friends, they can choose to become online friends (communicating using online applications) or offline friends (mostly using face-to-face communication). However, everyo

2015 多校赛 第二场 1002 (hdu 5301)

Description Your current task is to make a ground plan for a residential building located in HZXJHS. So you must determine a way to split the floor building with walls to make apartments in the shape of a rectangle. Each built wall must be paralled t