The 15th Zhejiang University Programming Contest

A
Find the Spy

/* ***********************************************
Author        :xryz
Email         :523689985@qq.com
Created Time  :2015/4/12 13:21:07
File Name     :\浙大校赛\a.cpp
************************************************ */

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

int main()
{
    int i,t,n,a[150];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        if(a[0]==a[1]) printf("%d\n",a[n-1]);       
        else printf("%d\n",a[0]);
    }
    return 0;
}

B
Valid Pattern Lock

/* ***********************************************
Author        :xryz
Email         :523689985@qq.com
Created Time  :2015/4/12 13:47:52
File Name     :\浙大校赛\b.cpp
************************************************ */

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

int mp[10][10],a[10],n,ans,vis[10],out[10];

void f1()
{
    memset(mp,0,sizeof(mp));
    mp[1][3]=2;mp[3][1]=2;
    mp[4][6]=5;mp[6][4]=5;
    mp[7][9]=8;mp[9][7]=8;
    mp[1][7]=4;mp[7][1]=4;
    mp[2][8]=5;mp[8][2]=5;
    mp[3][9]=6;mp[9][3]=6;
    mp[1][9]=5;mp[9][1]=5;
    mp[3][7]=5;mp[7][3]=5;
}

void dfs1(int cnt,int now)
{
    if(cnt==n)
    {
        ans++;
        return;
    }
    else
    for(int i=0;i<n;i++)
    {
        if(vis[a[i]]==0&&(mp[now][a[i]]==0||vis[mp[now][a[i]]]==1))
        {
            vis[a[i]]=1;
            dfs1(cnt+1,a[i]);
            vis[a[i]]=0;
        }
    }
    //return;
}
void dfs2(int cnt,int now)
{
    if(cnt==n)
    {
        for(int i=0;i<n-1;i++)
        {
            printf("%d ",out[i]);
        }
        printf("%d\n",out[n-1]);
        return;
    }
    else
    for(int i=0;i<n;i++)
    {
        if(vis[a[i]]==0&&(mp[now][a[i]]==0||vis[mp[now][a[i]]]==1))
        {
            vis[a[i]]=1;
            out[cnt]=a[i];
            dfs2(cnt+1,a[i]);
            vis[a[i]]=0;
        }
    }
    return ;
}
int main()
{
    int t,tmp;
    scanf("%d",&t);
    while(t--)
    {
        f1();
        scanf("%d",&n);
        for(int i=0;i<n;i++) scanf("%d",&a[i]);
        sort(a,a+n);
        ans=0;
        memset(vis,0,sizeof(vis));
        dfs1(0,0);
        printf("%d\n",ans);
        memset(vis,0,sizeof(vis));
        dfs2(0,0);
    }
    return 0;
}

G
Cylinder Candy

#include<stdio.h>
#include<math.h>
int main()
{
    double d,r,h,v,s;
    double pi=2*asin(1.0);
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf%lf",&r,&h,&d);
        s=2*d*r*pi*pi+2*(r*r+r*h+d*h+2*d*d)*pi;
        v=((6*d*(d*d+r*r)-2*d*d*d)*pi+3*r*d*d*pi*pi)/3+(r+d)*(r+d)*h*pi;
        printf("%.12f %.12f\n",v,s);
    }
    return 0;
}

H
Earthstone: Easy Version

/* ***********************************************
Author        :xryz
Email         :523689985@qq.com
Created Time  :2015/4/12 13:37:57
File Name     :\浙大校赛\b.cpp
************************************************ */

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

int main()
{
   int t,a1,a2,h1,h2;
   scanf("%d",&t);
   while(t--)
   {
       scanf("%d%d%d%d",&a1,&h1,&a2,&h2);
       if(a1==0) printf("Invalid\n");
       else
       {
           if(h1>a2) printf("%d %d ",a1,h1-a2);
           else printf("Discard ");
           if(h2>a1) printf("%d %d\n",a2,h2-a1);
           else printf("Discard\n");
       }
   }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

posted @ 2015-05-08 21:13  xryz  阅读(133)  评论(0编辑  收藏  举报