当前位置:网站首页>uva1325
uva1325
2022-08-05 04:59:00 【小刀刺大熊】
#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 1e6 + 7,maxm = 1007;
struct Node {
double len;
int first, second;
bool operator<(const Node& input) {
return len < input.len;
}
}node[maxn];
double x[maxm], y[maxm], z[maxm];
int p[maxm],n,sum[maxm],sum2[maxm];
#define _POW(x) (x) * (x)
//求距离
double GetLen(int a, int b) {
return sqrt(_POW(x[a] - x[b]) + _POW(y[a] - y[b]) + _POW(z[a] - z[b]));
}
//是不稳定星球
bool IsInstable(int index) {
//1的个数 与0的个数
int f0 = sum[index] - sum2[index], f1 = sum2[index];
return p[index] ? f1 < f0 : f0 < f1;
}
int main()
{
while (cin >> n) {
int cnt = 0;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i] >> z[i] >> p[i];
sum[i] = 1;
sum2[i] = p[i];
for (int j = 0; j < i; j++) {
node[cnt].first = i;
node[cnt].second = j;
node[cnt].len = GetLen(i, j);
cnt++;
}
}
sort(node, node + cnt);
int c = 0,ans = 0;
double r = 0;
for (int i = 0; i < cnt; i++) {
int first = node[i].first;
int second = node[i].second;
//first second 是否是不稳定的
bool f0 = IsInstable(first);
bool s0 = IsInstable(second);
//总次数
sum[first]++;sum[second]++;
//1的次数
sum2[first] += p[second];
sum2[second] += p[first];
bool f1 = IsInstable(first);
bool s1 = IsInstable(second);
//first second 发生变化了
if (f0 != f1) {
if (f1)c++;
else c--;
}
if (s0 != s1) {
if (s1)c++;
else c--;
}
if (i == cnt - 1 || node[i].len != node[i + 1].len) {
if (c > ans) {
ans = c;
r = node[i].len;
}
}
}
cout << ans << endl;
cout << fixed << setprecision(4) << r << endl;
}
return 0;
}
边栏推荐
- Mvi架构浅析
- 【学习笔记之菜Dog学C】动态内存管理之经典笔试题
- Flutter学习三-Flutter基本结构和原理
- dedecms后台生成提示读取频道信息失败的解决方法
- 社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
- A 35-year-old software testing engineer with a monthly salary of less than 2W, resigns and is afraid of not finding a job, what should he do?
- 判断语句_switch与case
- Flutter学习5-集成-打包-发布
- 数字孪生技术在电力系统中的应用现状
- how to measure distance from point to face in creo
猜你喜欢
Day019 方法重写与相关类的介绍
Application status of digital twin technology in power system
8.04 Day35-----MVC三层架构
[cesium] 3D Tileset model is loaded and associated with the model tree
AUTOCAD - dimension association
Develop your own node package
[cesium] element highlighting
【cesium】加载并定位 3D Tileset
u-boot debugging and positioning means
how to measure distance from point to face in creo
随机推荐
Application status of digital twin technology in power system
Day14 jenkins deployment
How to deal with DNS hijacking?
机器学习概述
App快速开发建设心得:小程序+自定义插件的重要性
Homework 8.4 Interprocess Communication Pipes and Signals
dedecms报错The each() function is deprecated
一篇博客通关Redis技术栈
Analyses the mainstream across technology solutions
Some conventional routines of program development (1)
for..in和for..of的区别
1007 Climb Stairs (greedy | C thinking)
write the story about us
u-boot debugging and positioning means
How to solve complex distribution and ledger problems?
【informix】解决启动报错大全,以及解决办法
延迟加载js方式async与defer区别
There are a lot of 4T hard drives remaining, prompting "No space left on device" insufficient disk space
1068 Find More Coins
[8.2] Code Source - [Currency System] [Coins] [New Year's Questions (Data Enhanced Edition)] [Three Stages]