SGU 416 Optimal Dartboard(找规律)

416. Optimal Dartboard
Time limit per test: 0.25 second(s) 
Memory limit: 262144 kilobytes
input: standard 
output: standard



A dartboard is a disc divided into  n segments, with each segment labeled with a distinct positive integer between 1 and  n. That integer indicates the score for hitting the segment. To make the game more interesting, the arrangement of numbers is chosen in such a way that the risk is maximized. The risk is estimated based on the differences in scores of adjacent segments. 

We're studying the following 'double-layered' structure of segments in this problem:

 

I.e.,  n is always even, and we split the disc into two layers of   parts along the circumference. We enumerate the segments in the following manner: the first segment is some outer segment, the second segment is the corresponding inner segment, the third segment is some adjacent outer segment, etc. An example of this enumeration is shown on the picture above. 

The total risk is defined as the sum of squared differences between the scores of adjacent segments. If the value assigned to segment  i is  a  i, then the risk is: 

R=∑  i=1  na  ia  i+22+∑  i=1  n/2a  2i-1a  2i2 

(we assume  a  n+1=a  1 and  a  n+2=a  2 in this formula). 

You are to place the numbers from 1 through  n into the segments in such a way that the total risk  R is maximized. 

Input
The input file contains an even integer number  n (6 ≤  n ≤ 100). 

Output
Output  n integer numbers:  a  1a  2,...,  a  n, separated with single spaces. In case there are several possible solutions, output any. 

Example(s)

sample input
sample output
10
2 9 7 4 6 5 3 8 10 1


题意:
给你一个偶数n,表示一个内环有n/2个空,外环也有n/2个空,且内外环的空一一对应的图。如题目中的图所示,它表示n为20的图形。现在你要把1到n这n个数往空里填,使得每两个相邻的空的数的差的平方和最大。然后按照图示顺序输出这n个数。

思路:
很明显,要想使差的平方和最大,最小的那一个周围肯定是最大的三个数,然后第二大的数旁边要放上第二小的数,然后第三大的数旁边要放上第三小的数,依次类推,很容易把这个环形的每个空按要求填满。那么接下来就只需要按要求输出就行了。随便列几个情况,很容易发现规律,当n/2为偶数的时候,我们只需要按大小小大或小大大小的顺序输出即可,当n/2为奇数的时候,除了中间那一组以外其余的仍然是大小小大或小大大小的顺序,而中间那一组只要不变就行了,具体看代码。

AC代码:
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <string>  
#include <cstdlib>  
#include <cmath>  
#include <vector>  
#include <queue>  
#include <map>  
#include <algorithm>  
#include <set>  
#include <functional>  
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9 + 5;
const int MAXN = 1005;
const int MOD = 1e9 + 7;
const double eps = 1e-8;
const double PI = acos(-1.0);
LL gcd(LL a, LL b) { return b == 0 ? a : gcd(b, a%b); }
LL ppow(LL a, LL b){LL res = 1;for (int i = 1; i <= b; i++)res *= a;return res;}

int ans[105];

int main()
{
	int i, n, p, q;
	bool flag1, flag2;
	while (scanf("%d", &n) != EOF)
	{
		flag2 = n % 4 == 0 ? false : true;
		p = 1;
		q = n;
		flag1 = true;
		i = 0;
		while (p<n)
		{
			if (flag1)
			{
				ans[++i] = max(p, q);
				ans[++i] = min(p, q);
				p += 2;
				q -= 2;
			}
			else
			{
				ans[++i] = min(p, q);
				ans[++i] = max(p, q);
				p += 2;
				q -= 2;
			}
			if (flag2 == true && p > q)//跳过中间这一组的异或步骤
			{
				flag2 = false;
				continue;
			}
			flag1 ^= 1;
		}
		for (int j = 1; j <= i; j++)
			if (j == 1)
				printf("%d", ans[j]);
			else
				printf(" %d", ans[j]);
		printf("\n");
	}
}


内容概要:《2024年中国城市低空经济发展指数报告》由36氪研究院发布,指出低空经济作为新质生产力的代表,已成为中国经济新的增长点。报告从发展环境、资金投入、创新能力、基础支撑和发展成效五个维度构建了综合指数评价体系,评估了全国重点城市的低空经济发展状况。北京和深圳在总指数中名列前茅,分别以91.26和84.53的得分领先,展现出强大的资金投入、创新能力和基础支撑。低空经济主要涉及无人机、eVTOL(电动垂直起降飞行器)和直升机等产品,广泛应用于农业、物流、交通、应急救援等领域。政策支持、市场需求和技术进步共同推动了低空经济的快速发展,预计到2026年市场规模将突破万亿元。 适用人群:对低空经济发展感兴趣的政策制定者、投资者、企业和研究人员。 使用场景及目标:①了解低空经济的定义、分类和发展驱动力;②掌握低空经济的主要应用场景和市场规模预测;③评估各城市在低空经济发展中的表现和潜力;④为政策制定、投资决策和企业发展提供参考依据。 其他说明:报告强调了政策监管、产业生态建设和区域融合错位的重要性,提出了加强法律法规建设、人才储备和基础设施建设等建议。低空经济正加速向网络化、智能化、规模化和集聚化方向发展,各地应准自身比较优势,实现差异化发展。
数据集一个高质量的医学图像数据集,专门用于脑肿瘤的检测和分类研究以下是关于这个数据集的详细介绍:该数据集包含5249张脑部MRI图像,分为训练集和验证集。每张图像都标注了边界框(Bounding Boxes),并按照脑肿瘤的类型分为四个类别:胶质瘤(Glioma)、脑膜瘤(Meningioma)、无肿瘤(No Tumor)和垂体瘤(Pituitary)。这些图像涵盖了不同的MRI扫描角度,包括矢状面、轴面和冠状面,能够全面覆盖脑部解剖结构,为模型训练提供了丰富多样的数据基础。高质量标注:边界框是通过LabelImg工具手动标注的,标注过程严谨,确保了标注的准确性和可靠性。多角度覆盖:图像从不同的MRI扫描角度拍摄,包括矢状面、轴面和冠状面,能够全面覆盖脑部解剖结构。数据清洗与筛选:数据集在创建过程中经过了彻底的清洗,去除了噪声、错误标注和质量不佳的图像,保证了数据的高质量。该数据集非常适合用于训练和验证深度学习模型,以实现脑肿瘤的检测和分类。它为开发医学图像处理中的计算机视觉应用提供了坚实的基础,能够帮助研究人员和开发人员构建更准确、更可靠的脑肿瘤诊断系统。这个数据集为脑肿瘤检测和分类的研究提供了宝贵的资源,能够帮助研究人员开发出更准确、更高效的诊断工具,从而为脑肿瘤患者的早期诊断和治疗规划提供支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值