Uvalive 4123 - Glenbow Museum(思维)

The famous Glenbow Museum in Calgary isWestern Canada’s largest museum, with exhibits ranging from art to culturalhistory to mineralogy. A brand new section is being planned, devoted tobrilliant computer programmers just like you. Unfortunately, due to lack ofspace, the museum is going to have to build a brand new building and relocateinto it. The size and capacity of the new building differ from those of theoriginal building. But the floor plans of both buildings are orthogonalpolygons. An orthogonal polygon is a polygon whose internal angles are either90 or 270. If 90 angles are denoted as R (Right) and 270 angles are denoted asO (Obtuse) then a string containing only R and O can roughly describe anorthogonal polygon. For example, a rectangle (Figure 1) is the simplestorthogonal polygon and it can be described as RRRR (the angles are listed incounter-clockwise order, starting from any corner). Similarly, a cross-shapedorthogonal polygon (Figure 2) can be described by the sequence RRORRORRORRO,RORRORRORROR, or ORRORRORRORR. These sequences are called angle strings.

Of course, anangle string does not completely specify the shape of a polygon — it saysnothing about the length of the sides. And some angle strings cannot possiblydescribe a valid orthogonal polygon (RRROR, for example). To complicate thingsfurther, not all orthogonal polygons are acceptable floor plans for the museum.A museum contains many valuable objects, and these objects must be guarded. Dueto cost considerations, no floor can have more than one guard. So a floor planis acceptable only if there is a place within the floor from which one guardcan see the entire floor. Similarly, an angle string is acceptable only if itdescribes at least one acceptable polygon. Note that the cross-shaped polygonin Figure 2 can be guarded by someone standing in the center, so it is acceptable.Thus the angle string RRORRORRORRO is acceptable, even though it also describesother polygons that cannot be properly guarded by a single guard. Help thedesigners of the new building determine how many acceptable angle strings thereare of a given length.

 

Input

The input file contains several test cases.Each test case consists of a line containing a positive integer L (1 ≤ L ≤1000), which is the desired length of an angle string. The input will end witha line containing a single zero.

 

Output

For each test case, print a line containingthe test case number (beginning with 1) followed by the number of acceptableangle strings of the given length. Follow the format of the sample output.

 

Sample Input

4

6

0

 

Sample Output

Case 1: 1

Case 2: 6


【题意】

对于一个边平行于坐标轴的多边形,我们可以用一个由R和O组成的序列描述。从某个顶点开始按照逆时针走,碰到一个90°内角记R,270°内角记O,形成一个角度序列。给定正整数L,有多少个长为L的角度序列对应一个星型多边形,即多边形中存在一点可以看到多边形边界上的每一个点。多边形每条边的长度任意。

 

【思路】

   多边形的长度l就是顶点数n,当n为奇数或者n<4时无解。设有x个O,y个R,则由内角和公式(n-2)*180=270x+90y,和x+y=n联立可得x=(n-4)/2,y=(n+4)/2。通过画图可以看出构成星型多边形必须由4个阶梯序列OROROR…ORO和4个RR构成。也就是说序列中的O不能相邻。问题转换成了,x=(n-4)/2个O,y=(n+4)/2个R构成一个序列,且O不相邻(首尾也不能同时为O)。用组合数学推公式,假设现在序列的首部和尾部都是R,那么用隔板法将O插入,有y-1个位置可以插入,即C(x,y-1);假设序列首部是R,尾部是O,那么有y-1个位置可以插入,即C(x-1,y-1),同理首部是O,尾部是R也是C(x-1,y-1),求和即可得到ans = n*n*(n+2)*(n-2)/192


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n;

int main() {
	int kase = 1;
	while (scanf("%lld", &n) == 1 && n) {
		printf("Case %d: ", kase++);
		if (n < 4 || n & 1) {
			printf("0\n");
			continue;
		}
		printf("%lld\n", n*n*(n+2)*(n-2)/192);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
东南亚位于我国倡导推进的“一带一路”海陆交汇地带,作为当今全球发展最为迅速的地区之一,近年来区域内生产总值实现了显著且稳定的增长。根据东盟主要经济体公布的最新数据,印度尼西亚2023年国内生产总值(GDP)增长5.05%;越南2023年经济增长5.05%;马来西亚2023年经济增速为3.7%;泰国2023年经济增长1.9%;新加坡2023年经济增长1.1%;柬埔寨2023年经济增速预计为5.6%。 东盟国家在“一带一路”沿线国家中的总体GDP经济规模、贸易总额与国外直接投资均为最大,因此有着举足轻重的地位和作用。当前,东盟与中国已互相成为双方最大的交易伙伴。中国-东盟贸易总额已从2013年的443亿元增长至 2023年合计超逾6.4万亿元,占中国外贸总值的15.4%。在过去20余年中,东盟国家不断在全球多变的格局里面临挑战并寻求机遇。2023东盟国家主要经济体受到国内消费、国外投资、货币政策、旅游业复苏、和大宗商品出口价企稳等方面的提振,经济显现出稳步增长态势和强韧性的潜能。 本调研报告旨在深度挖掘东南亚市场的增长潜力与发展机会,分析东南亚市场竞争态势、销售模式、客户偏好、整体市场营商环境,为国内企业出海开展业务提供客观参考意见。 本文核心内容: 市场空间:全球行业市场空间、东南亚市场发展空间。 竞争态势:全球份额,东南亚市场企业份额。 销售模式:东南亚市场销售模式、本地代理商 客户情况:东南亚本地客户及偏好分析 营商环境:东南亚营商环境分析 本文纳入的企业包括国外及印尼本土企业,以及相关上下游企业等,部分名单 QYResearch是全球知名的大型咨询公司,行业涵盖各高科技行业产业链细分市场,横跨如半导体产业链(半导体设备及零部件、半导体材料、集成电路、制造、封测、分立器件、传感器、光电器件)、光伏产业链(设备、硅料/硅片、电池片、组件、辅料支架、逆变器、电站终端)、新能源汽车产业链(动力电池及材料、电驱电控、汽车半导体/电子、整车、充电桩)、通信产业链(通信系统设备、终端设备、电子元器件、射频前端、光模块、4G/5G/6G、宽带、IoT、数字经济、AI)、先进材料产业链(金属材料、高分子材料、陶瓷材料、纳米材料等)、机械制造产业链(数控机床、工程机械、电气机械、3C自动化、工业机器人、激光、工控、无人机)、食品药品、医疗器械、农业等。邮箱:market@qyresearch.com

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值