2018ACM-ICPC南京区域赛【待填】

含【最小球覆盖】模板。

题面pdf

https://codeforc.es/gym/101981/attachments/download/7891/20182019-acmicpc-asia-nanjing-regional-contest-en.pdf

A---Adrien and Austin【博弈论】

J---Prime Game【数论】

G---Pyramid【数论】【规律】【递推式】

I---Magic Potion【网络流】

题意:

思路:

D---Country Meow【最小球覆盖】

题意:

三维空间中有$n$个点,现在要在空间中找一个点,使得他到这$n$个点最远的距离最小。

思路:

就是一个最小球覆盖的板子题。找的模拟退火的板子cf过不了了。

用的三分的板子直接就过了。

#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<climits>
#include<map>
using namespace std;
typedef long long LL;
#define N 100010
#define pi 3.1415926535
#define inf 0x3f3f3f3f

const int maxn = 105;
const double eps = 1e-7;
typedef struct {double p[3];}point;
point a[maxn];
int n;
double cal(point now)
{
    double ans=0.0;
    for(int i=0;i<n;i++)
        ans=max(ans,sqrt((a[i].p[0]-now.p[0])*(a[i].p[0]-now.p[0])+(a[i].p[1]-now.p[1])*(a[i].p[1]-now.p[1])+(a[i].p[2]-now.p[2])*(a[i].p[2]-now.p[2])));
    return ans;
}
point del(point now,int cnt)
{
    if(cnt>=3)
        return now;
    double r=100000,l=-100000;
    double dr,dl;
    point tp1,tp2,ans1,ans2,ans;
    tp1=tp2=ans=now;
    while(r-l>eps)
    {
        dr=(2*r+l)/3;
        dl=(2*l+r)/3;
        tp1.p[cnt]=dl;
        tp2.p[cnt]=dr;
        ans1=del(tp1,cnt+1);
        ans2=del(tp2,cnt+1);
        if(cal(ans1)>cal(ans2))
        {
            l=dl;
            ans=ans1;
        }
        else
        {
            r=dr;
            ans=ans2;
        }
    }
    return ans;
}

int main()
{ // freopen("t.txt","r",stdin);
    //ios::sync_with_stdio(false);
    //double ans;
    while(~scanf("%d", &n))
    {
        for(int i=0; i<n; i++)
            //cin>>node[i].x>>node[i].y>>node[i].z;
            scanf("%lf%lf%lf",&a[i].p[0],&a[i].p[1],&a[i].p[2]);
        //minball(n);
        //cout<<ans<<endl;
        point ans;
        printf("%.7f\n",cal(del(ans, 0)));
    }
    return 0;
}
View Code

K---Kangaroo Puzzle

题意:

思路:

这题代码可不能折叠啊。队友太强了!

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include <bits/stdc++.h>
 4 
 5 using namespace std;
 6 const int MAX_N = 10;
 7 char c[4] = {'L', 'R', 'U', 'D'};
 8 
 9 int main()
10 {
11     int N, M;
12     cin >> N >> M;
13     string s;
14     for (int i = 1; i <= N; i++)
15         cin >> s;
16     int cnt = 0;
17     srand(56346275);
18     while (cnt++ < 50000) {
19         printf("%c", c[rand()%4]);
20     }
21     puts("");
22     return 0;
23 }

M---

猜你喜欢

转载自www.cnblogs.com/wyboooo/p/9976190.html
今日推荐