Inscribed Figures(思维)
The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier.
Future students will be asked just a single question. They are given a sequence of integer numbers a1,a2,…,ana1,a2,…,an, each number is from 11 to 33 and ai≠ai+1ai≠ai+1 for each valid ii. The ii-th number represents a type of the ii-th figure:
- circle;
- isosceles triangle with the length of height equal to the length of base;
- square.
The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that:
- (i+1)(i+1)-th figure is inscribed into the ii-th one;
- each triangle base is parallel to OX;
- the triangle is oriented in such a way that the vertex opposite to its base is at the top;
- each square sides are parallel to the axes;
- for each ii from 22 to nn figure ii has the maximum possible length of side for triangle and square and maximum radius for circle.
Note that the construction is unique for some fixed position and size of just the first figure.
The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it?
So can you pass the math test and enroll into Berland State University?
The first line contains a single integer nn (2≤n≤1002≤n≤100) — the number of figures.
The second line contains nn integer numbers a1,a2,…,ana1,a2,…,an (1≤ai≤31≤ai≤3, ai≠ai+1ai≠ai+1) — types of the figures.
The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise.
If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type.
3
2 1 3
Finite
7
3
1 2 3
Infinite
Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way.
The distinct points where figures touch are marked red.
In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points.
感觉这题放在div2的第一题有点难题意:给出N个图形(1代表圆, 2代表高等于底的等腰三角形, 3代表矩形, 相邻图形不会相等), 从左到右右边的内接在左边的图形里面, 要求尽量最大而且各种平行的放, 也就是如图. 求图形中点的个数.思路:思考每个图形的贡献,特判3 1 2代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
int n;
int a[maxn];
int main()
{
cin>>n;
for(int t=;t<=n;t++)
{
scanf("%d",&a[t]);
}
int ans=;
int flag=;
for(int t=;t<=n;t++)
{
if(a[t]==)
{
if(a[t-]==)
ans+=;
else
ans+=;
}
else if(a[t]==)
{
if(a[t-]==)
ans+=;
else
flag = ;
}else
{
if(a[t-]==)
ans+=;
else if(a[t-]==)
flag=;
}
}
for(int t = ; t <= n; t++)
{
if(a[t-]== && a[t-]== && a[t]==)
ans--;
}
if(flag)
{
cout<<"Infinite"<<endl;
}
else
{
cout<<"Finite"<<endl;
cout<<ans<<endl;
}
return ;
}
Inscribed Figures(思维)的更多相关文章
- Educational Codeforces Round 64 (Rated for Div. 2)题解
Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...
- Educational Codeforces Round 64 (Rated for Div. 2) A,B,C,D,E,F
比赛链接: https://codeforces.com/contest/1156 A. Inscribed Figures 题意: 给出$n(2\leq n\leq 100)$个数,只含有1,2,3 ...
- Educational Codeforces Round 64 选做
感觉这场比赛题目质量挺高(A 全场最佳),难度也不小.虽然 unr 后就懒得打了. A. Inscribed Figures 题意 给你若干个图形,每个图形为三角形.圆形或正方形,第 \(i\) 个图 ...
- Codeforces Edu Round 64 A-D
A. Inscribed Figures 分类讨论打表即可. PS:这道题翻译有歧义. 这样稍微翻转一下,就可以是\(7\)个交点呀...(大概是我没看英文题干导致的惨案) #include < ...
- Figures Inscribed in Curves (曲线上的图形)
Figures Inscribed in Curves\text{Figures Inscribed in Curves}Figures Inscribed in Curves A short tou ...
- Latex--TikZ和PGF--高级文本绘图,思维绘图,想到--得到!
Latex--TikZ和PGF--高级文本绘图,思维绘图,想到--得到! TikZ和PGF是一种用在TeX上的CLI绘图工具.CLI和GUI是两种常见的绘图方式,前者是所想即所得(WYTIWYG)的, ...
- [C#][算法] 用菜鸟的思维学习算法 -- 马桶排序、冒泡排序和快速排序
用菜鸟的思维学习算法 -- 马桶排序.冒泡排序和快速排序 [博主]反骨仔 [来源]http://www.cnblogs.com/liqingwen/p/4994261.html 目录 马桶排序(令人 ...
- Photoshop、Illustrator思维导图笔记
半年前学习Photoshop时记得的思维导图笔记,可能不是很全,常用的基本都记下了.
- CYQ.Data 从入门到放弃ORM系列:开篇:自动化框架编程思维
前言: 随着CYQ.Data 开始回归免费使用之后,发现用户的情绪越来越激动,为了保持这持续的激动性,让我有了开源的念头. 同时,由于框架经过这5-6年来的不断演进,以前发的早期教程已经太落后了,包括 ...
随机推荐
- JConsole、VisualVM 依赖的 JMX 技术到底是什么
我是风筝,公众号「古时的风筝」,一个兼具深度与广度的程序员鼓励师,一个本打算写诗却写起了代码的田园码农! 文章会收录在 JavaNewBee 中,更有 Java 后端知识图谱,从小白到大牛要走的路都在 ...
- 文字识别还能这样用?通过Python做文字识别到破解图片验证码
前期准备 1. 安装包,直接在终端上输入pip指令即可: # 发送浏览器请求 pip3 install requests # 文字识别 pip3 install pytesseract # 图片处理 ...
- Unity目录结构设置
摄像机 Main Camera 跟随主角移动,不看 UI 剧情摄像机 当进入剧情时,可以关闭 main camera,启用剧情摄像机,不看 UI UI 摄像机 看 UI Unity编辑器常用的sett ...
- JVM系列之:再谈java中的safepoint
目录 safepoint是什么 safepoint的例子 线程什么时候会进入safepoint safepoint是怎么工作的 总结 safepoint是什么 java程序里面有很多很多的java线程 ...
- 使用 gopacket 进行数据包捕获,注入和分析
原文链接:https://www.devdungeon.com/content/packet-capture-injection-and-analysis-gopacket 接口文档:https:// ...
- govendor 使用
govendor是go语言依赖管理工具,推荐使用 https://github.com/kardianos/govendor 这个版本. go get -u -v github.com/kardian ...
- Robot Framework(2)——简单运行案例
1.打开RIDE 之前介绍的3种方式都可以 2.创建工程和测试套件 1>点击File-New Project ①Name:工程命名 ②Parent Directory:上级目录,工程会创建在这个 ...
- (转载)std::enable_if 的几种用法 c++11
今天看confluo源码中看到了std::enable_if这一个我不了解的语法,所以记录下来 转载地址:https://yixinglu.gitlab.io/enable_if.html std:: ...
- muduo源码解析8-date类
date class date:copyable { }: 作用: 此类作用主要是实现年月日和julianDay的互相转换内部最重要的一个数据成员m_julianDayNumber在mymuduo:: ...
- asp.net Core3.1自定义权限体系-菜单和操作按钮权限
我们在做项目项目,经常会碰到权限体系,权限体系属于系统架构的一个最底层的功能,也是非常重要的功能,几乎在每个项目都会用到.那么我们该如何设计一个比较合理的且扩展性较强的权限体系呢? 经过多天的摸索,参 ...