日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

【UVA】10012 - How Big Is It?(暴力)

發(fā)布時(shí)間:2025/5/22 68 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【UVA】10012 - How Big Is It?(暴力) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

使用DFS枚舉所有的安排。每次加入后,當(dāng)一個(gè)圓。他的立場(chǎng)是最大的,并已加入了圓環(huán)中的所有切線位置前面。

14383635 10012 How Big Is It? Accepted C++ 0.086 2014-10-20 11:07:33

#include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; typedef double Dou; #define FOR(i,n) for(int i = 0; i < n; i ++) const int maxn = 10; int n,vis[maxn]; Dou ans,r[maxn]; struct POS{ //圓心位置就是(x,r)Dou x,r; //橫坐標(biāo),半徑 }pos[maxn]; Dou check(int cur,int k){Dou ret = r[k];FOR(i,cur){Dou a = pos[i].r + r[k];Dou b = pos[i].r - r[k];Dou c = sqrt(a * a - b * b);ret = max(ret,pos[i].x + c);}pos[cur].x = ret; pos[cur].r = r[k];return ret + r[k]; } void dfs(int cur,double L){if(ans != -1 && L > ans) return;if(cur == n){Dou ret;for(int i = 0; i < cur; i++){if(i == 0) ret = pos[i].x + pos[i].r;else ret = max(ret,pos[i].x + pos[i].r);}ans = (ans == -1) ?

ret : min(ans,ret); return; } FOR(i,n) if(!vis[i]){ vis[i] = 1; dfs(cur + 1,check(cur,i)); vis[i] = 0; } return; } int main(){ int T; scanf("%d",&T); while(T--){ scanf("%d",&n); ans = -1; memset(vis,0,sizeof(vis)); FOR(i,n) scanf("%lf",&r[i]); dfs(0,0.0); printf("%.3f\n",ans); } return 0; }


《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的【UVA】10012 - How Big Is It?(暴力)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。