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年来的不断演进,以前发的早期教程已经太落后了,包括 ...
随机推荐
- Elasticsearch权威指南(中文版)
Elasticsearch权威指南(中文版) 下载地址: https://pan.baidu.com/s/1bUGJmwS2Gp0B32xUyXxCIw 扫码下面二维码关注公众号回复100010 获取 ...
- 朴素贝叶斯分类器基本代码 && n折交叉优化 2
这个代码基于上一个代码 不同的是:读取了txt文件,改变了min_ft与max_ft的参数 import re import pandas as pd import warnings import n ...
- canvas小画板——(2)荧光笔效果
我们在上一篇文章中讲了如何绘制平滑曲线 canvas小画板——(1)平滑曲线. 透明度实现荧光笔 现在我们需要加另外一种画笔效果,带透明度的荧光笔.那可能会觉得绘制画笔的时候加上透明度就可以了.我们来 ...
- JS 导航条切换案例
HTML代码: <div class="tab"> <div class="tab_list"> <ul> <li c ...
- Python 切分数组,将一个数组均匀切分成多个数组
Python 切分数组 将一个数组,均分为多个数组 代码 # -*- coding:utf-8 -*- # py3 def list_split(items, n): return [items[i: ...
- 【Python笔记】2020年7月22日练习=[定义一个函数quadratic(a, b, c),接收3个参数,返回一元二次方程的两个解]
学习教程:廖雪峰-Python教程-函数-函数定义 学习记录:[定义一个函数quadratic(a, b, c),接收3个参数,返回一元二次方程的两个解] 学习心得: 1.对问题进行判断分析后再下手. ...
- springboot多环境配置文件
一.关于springboot的配置文件 springboot的配置文件主要有两种:properties文件和yml文件,我们只要选择一种使用就可以了.我们通过properties文件介绍一下配置的方式 ...
- JavaScript 回调函数的简单示例
回调函数 回调函数也被称为高阶函数 所谓高阶函数,就是说值 函数作为参数被传递或者返回值输出 操作函数的函数称为 高阶函数 把一段可执行的代码(一个函数)作为参数传递给其他的代码(另一个函数),并在需 ...
- eric4 中 pyqt .py文件结尾的 代码
if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) ui = MainWindow() ...
- Dubbo系列之 (四)服务订阅(1)
辅助链接 Dubbo系列之 (一)SPI扩展 Dubbo系列之 (二)Registry注册中心-注册(1) Dubbo系列之 (三)Registry注册中心-注册(2) Dubbo系列之 (四)服务订 ...