日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UVA 2474 - Balloons in a Box 爆搜

發布時間:2023/12/2 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UVA 2474 - Balloons in a Box 爆搜 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2474 - Balloons in a Box

題目連接:

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=99999999&page=show_problem&category=36&problem=475&mosmsg=Submission+received+with+ID+1967446

Description

You must write a program that simulates placing spherical balloons into a rectangular box.
The simulation scenario is as follows. Imagine that you are given a rectangular box and a set of
points. Each point represents a position where you might place a balloon. To place a balloon at a
point, center it at the point and inflate the balloon until it touches a side of the box or a previously
placed balloon. You may not use a point that is outside the box or inside a previously placed balloon.
However, you may use the points in any order you like, and you need not use every point. Your objective
is to place balloons in the box in an order that maximizes the total volume occupied by the balloons.
You are required to calculate the volume within the box that is not enclosed by the balloons.

Input

The input consists of several test cases. The first line of each test case contains a single integer n
that indicates the number of points in the set (1 ≤ n ≤ 6). The second line contains three integers
that represent the (x, y, z) integer coordinates of a corner of the box, and the third line contains the
(x, y, z) integer coordinates of the opposite corner of the box. The next n lines of the test case contain
three integers each, representing the (x, y, z) coordinates of the points in the set. The box has non-zero
length in each dimension and its sides are parallel to the coordinate axes.
The input is terminated by the number zero on a line by itself.

Output

For each test case print one line of output consisting of the test case number followed by the volume of
the box not occupied by balloons. Round the volume to the nearest integer. Follow the format in the
sample output given below.
Place a blank line after the output of each test case.

Sample Input

2
0 0 0
10 10 10
3 3 3
7 7 7
0

Sample Output

Box 1: 774

Hint

題意

將n個氣球放到一個長方體盒子里面, 然后氣球會一直膨脹, 直到碰到盒壁或者其他氣球. 先要求你找到一個放氣球的順序, 使得最后最后氣球占據的體積最大.

數據規模: 1≤n≤6

題解:

直接爆搜就好了,數據范圍很小……

代碼

#include<bits/stdc++.h> using namespace std; const int maxn = 10; const double eps = 1e-8; const double pi = acos(-1.0); double sqr(double x) {return x*x; } double dis(double x1,double y11,double z1,double x2,double y2,double z2) {return sqrt(sqr(x1-x2)+sqr(y11-y2)+sqr(z1-z2)); } int n; double x[maxn],y[maxn],z[maxn],ans,r[maxn]; int vis[maxn],u[maxn],cas; double x1,y11,z1,x2,y2,z2,a,b,c; void QAQ() {memset(vis,0,sizeof(vis)); } void dfs(int cnt,double v) {if(cnt>=n){ans=min(ans,v);return;}for(int i=0;i<n;i++){if(vis[i])continue;vis[i]=1,u[cnt]=i;r[cnt]=min(x[i],a-x[i]);r[cnt]=min(r[cnt],min(y[i],b-y[i]));r[cnt]=min(r[cnt],min(z[i],c-z[i]));for(int j=0;j<cnt;j++){double d = dis(x[i],y[i],z[i],x[u[j]],y[u[j]],z[u[j]]);r[cnt]=min(r[cnt],d-r[j]);}r[cnt]=max(r[cnt],0.0);dfs(cnt+1,v-4.0/3.0*pi*r[cnt]*r[cnt]*r[cnt]);vis[i]=0;} } void TAT() {cas++;scanf("%lf%lf%lf%lf%lf%lf",&x1,&y11,&z1,&x2,&y2,&z2);a=fabs(x1-x2),b=fabs(y11-y2),c=fabs(z1-z2);x1=min(x1,x2),y11=min(y11,y2),z1=min(z1,z2);for(int i=0;i<n;i++){scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);x[i]-=x1,y[i]-=y11,z[i]-=z1;}ans=a*b*c;dfs(0,a*b*c);printf("Box %d: %.0f\n\n",cas,round(ans+eps)); } int main() {while(scanf("%d",&n)!=EOF){if(n==0)break;QAQ();TAT();} }

轉載于:https://www.cnblogs.com/qscqesze/p/5567636.html

總結

以上是生活随笔為你收集整理的UVA 2474 - Balloons in a Box 爆搜的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 在线观看国产精品入口男同 | 欧美成人xxxx | 日韩人妻精品在线 | 精产国产伦理一二三区 | 久久久久夜夜夜精品国产 | 国产精品99精品无码视 | 亚洲色图 美腿丝袜 | 欧美freesex黑人又粗又大 | 日韩精品在线观看一区二区 | 秋霞7777鲁丝伊人久久影院 | 欧美综合区 | 91亚洲精品在线观看 | 精品91久久久 | 特种兵之深入敌后高清全集免费观看 | 成年人性视频 | 久久婷婷亚洲 | 动漫av在线 | 国产精品乱码妇女bbbb | 久久久夜色精品亚洲 | 公肉吊粗大爽色翁浪妇视频 | 免费在线国产精品 | 亚洲成人av综合 | 丁香激情五月少妇 | 欧美日韩国产高清 | 欧美精品国产一区二区 | 欧美美女色图 | 男人的天堂久久 | 女性裸体瑜伽无遮挡 | 欧美性猛交ⅹxx乱大交 | 亚洲一区二区三区中文字幕 | 免费无码又爽又黄又刺激网站 | 无码精品人妻一区二区三区影院 | 日本一级三级三级三级 | 亚洲视频国产 | 成人精品视频在线播放 | 欧美一区二区三区四区在线 | 国产精品一区二区三区四 | 欧美午夜精品久久久 | 欧美资源| 亚洲激情专区 | 久草资源在线播放 | 国产搞逼视频 | 国产sm主人调教女m视频 | 国产传媒av| 亚洲综合久久av | 奇米影视第四色7777 | www.精品久久 | 亚洲视频导航 | 成人依依 | 精品影片一区二区入口 | 国产成年人网站 | 人人干人人插 | 国产一区av在线 | 久久精品国产99国产 | 国产一区二区三区免费在线观看 | 一区二区av在线 | 欧美xxxx性 | 亚洲黄a| 在线观看成人免费视频 | 国产欧美日韩久久 | 精品在线播放 | 亚洲久久影院 | 久久精品视频一区二区三区 | 国产精品2020 | av剧情在线 | 欧美三级韩国三级日本三斤在线观看 | 最新91在线 | 孕妇爱爱视频 | 国产精品成人3p一区二区三区 | 少妇高潮灌满白浆毛片免费看 | 国产精品资源网站 | 亚洲免费在线观看 | 无码人妻av一区二区三区波多野 | 久久精品欧美日韩 | 久久精品久久久久久久 | www.97视频| 激情综合网五月婷婷 | 校园春色中文字幕 | 污视频网站入口 | 国产精品视频亚洲 | 日韩精品一区二区三区在线观看 | 99国产精品久久久 | 免费网站91 | 亚洲国产大片 | 色呦呦中文字幕 | 国产精品美女久久久久久久久 | 青青草亚洲 | www.男人天堂.com | 国产乱码精品 | 色就色欧美 | 中文字幕在线观看不卡 | 黄色一级片在线播放 | 在线看一区二区 | 久久夜精 | 免费观看一区二区三区 | 欧美精品乱码视频一二专区 | 特黄一区 | 日韩影视一区二区三区 | 久久亚洲av无码西西人体 |