Clockwise

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

Saya have a long necklace with N beads, and she signs the beads from 1 to N. Then she fixes them to the wall to show N-1 vectors – vector i starts from bead i and end up with bead i+1.

One day, Kudo comes to Saya’s home, and she sees the beads on the wall. Kudo says it is not beautiful, and let Saya make it better.

She says: “I think it will be better if it is clockwise rotation. It means that to any vector i (i < N-1), it will have the same direction with vector i+1 after clockwise rotate T degrees, while 0≤T<180.”

It is hard for Saya to reset the beads’ places, so she can only remove some beads. To saving the beads, although she agrees with Kudo’s suggestion, she thinks counterclockwise rotation is also acceptable. A counterclockwise rotation means to any vector i (i < N-1), it will have the same direction with vector i+1 after counterclockwise rotate T degrees, while 0 < T ≤ 180.”

Saya starts to compute at least how many beads she should remove to make a clockwise rotation or a counterclockwise rotation.

Since the necklace is very-very long, can you help her to solve this problem?

输入

The input consists of several test cases.
The first line of input in each test case contains one integer N (2<N≤300), which represents the number of beads.
Each of the next N lines contains two integer x and y, represents the coordinate of the beads. You can assume that 0<x,y<10000.
The last case is followed by a line containing one zero.

输出

For each case, print your answer with the following format:
 If it is clockwise rotation without removing any beads, please print “C; otherwise if it is counterclockwise rotation without removing any beads, print “CC” instead; otherwise, suppose remove at least x beads to make a clockwise rotation and remove at least y beads to make a counterclockwise rotation. If xy, print “Remove x bead(s), C”, otherwise print “Remove y bead(s), CC” instead.
Your output format should imitate the sample output. Print a blank line after each test case.

示例输入

31 12 23 331 12 21 141 12 23 32 20

示例输出

CCCRemove 1 bead(s), C
#include <bits/stdc++.h>
#define LL long long
#define eps 1e-10
using namespace std;class Point
{
public:double x, y;Point(double x = 0, double y = 0):x(x),y(y) {}
};
Point p[310];
int dp[310][310];
Point operator - (Point a, Point b)
{return Point(a.x-b.x, a.y-b.y);
}
double Cross(Point a, Point b)
{return a.x*b.y-b.x*a.y;
}
double Dot(Point a, Point b)
{return a.x* b.x + a.y * b.y;
}bool Check(int i, int j, int k, bool f)
{if(!k) return true;Point v1 = p[i] - p[j];Point v2 = p[j] - p[k];double x = Cross(v1, v2);if(fabs(x) < eps){double d = Dot(v1,v2);if(d > eps) return f;return !f;}else if(x > eps) return f;return !f;
}int main()
{int n;while(~scanf("%d",&n) && n){for(int i=1; i<=n; i++){scanf("%lf %lf", &p[i].x, &p[i].y);}int ans1 = 0;int ans2 = 0;memset(dp, 0, sizeof(dp));for(int i=2; i<=n; i++){for(int j=1; j<i; j++){int MAX = 0;for(int k=0; k<i; k++)if(Check(i, j, k, true)) MAX = max(MAX, dp[k][j]+1);dp[j][i] = MAX;ans1 = max(dp[j][i],ans1);}}memset(dp, 0, sizeof(dp));for(int i=2; i<=n; i++){for(int j=1; j<i; j++){int MAX = 0;for(int k=0; k<i; k++)if(Check(i, j, k, false)) MAX = max(MAX, dp[k][j]+1);dp[j][i] = MAX;ans2 = max(dp[j][i], ans2);}}if(ans1 == n-1)printf("C\n");else if(ans2 == n-1)printf("CC\n");else if(ans1 >= ans2)printf("Remove %d bead(s), C\n", n-1-ans1);elseprintf("Remove %d bead(s), CC\n", n-1-ans2);printf("\n");}return 0;
}

山东省第一届ACM省赛 C SDUT 2153 Clockwise相关推荐

  1. 山东省第一届ACM省赛 H SDUT 2158 Hello World!(穷举)

    Hello World! Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 We know that Ivan gives Saya ...

  2. sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)

    Clockwise Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...

  3. 第一届 ACM省赛山东省 Emergency

    Emergency Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Kudo's real name is not Kudo. H ...

  4. [2010山东省第一届ACM大学生程序设计竞赛]——Greatest Number

    Greatest Number 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2157 题 ...

  5. SDNU 1136.Balloons【山东省第一届ACM】【7月20】

    Balloons 原题贴上,不给链接了啊. Description Both Saya and Kudo like balloons. One day, they heard that in the ...

  6. 2021-SZTU第一届acm校赛总结

    关于题目: 我们队上来找到签到题,一个上去签,我和另外一个继续看题,我从后往前,他从前往后.后边的题目普遍是中文,难度也更高.然后他们两个就讨论一题签一题,干掉四题.我看了一道区间操作相关的题目,最近 ...

  7. [2010山东ACM省赛] Greatest Number(数的组合+二分搜索)

    Greatest Number Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Saya likes math, because ...

  8. 2017年山东省ACM省赛总结

    2017年山东省ACM省赛总结 ----但求努力到问心无愧 这次比赛我们是作为友谊队去的,本来我们队选拔赛成绩并不是很好,是去不了的,但伟大的教主大人牛逼地又要到了几个省赛友谊队的名额,才让我们有这次 ...

  9. 第十届山东省ACM省赛总结

    Author:Houge Date:2019-5-15 前言(Day 0) 开始打竞赛的第一场正式比赛,距离入门竞赛不过半年之久.很幸运第一次打的比赛就在自己的大学举行,山东省第十届省赛in济南大学, ...

最新文章

  1. linux 上操作mysql
  2. redis取出list最边的一个_这几个Redis使用技巧,让你的程序快如闪电
  3. Flutter之Align
  4. 深度隐式表达系列 (二)
  5. OpenShift 4 - DevSecOps Workshop (9) - 向Dev环境部署应用镜像
  6. java 类型推导_Java10类型推导
  7. python3.6网络爬虫_python3.6网络爬虫
  8. 3篇SCI定A类博士!直聘副教授七级!有偿70㎡住房+30万安家费+25万科启
  9. 物流配送信息管理系统java_基于jsp的物流配送管理系统-JavaEE实现物流配送管理系统 - java项目源码...
  10. 51单片机下载完程序后不亮_单片机实用工具大全,超级赞,工程师必备!
  11. 信号与系统:希尔伯特变换
  12. linux 默认ssh端口号,CentOS/Linux 修改默认SSH端口号
  13. word添加自定义样式(导入normal.dotm)
  14. python使用 urllib.unquote乱码的原因
  15. PyTorch 报错:TypeError: Cannot handle this data type: (1, 1, 512), |u1 (已解决)
  16. 泛微OA二次开发环境搭建 ecology二次开发
  17. CSS多列等高如何实现?
  18. 生活美学 | 8种咖啡冲煮器具分别有什么特点
  19. laravel 将汉字转化成拼音的库
  20. 【软件工程习题(含参考答案)】总复习

热门文章

  1. 计算机寄存器组的功能,寄存器的作用
  2. Linux虚拟机安装JDK
  3. 使用Matplotlib的条形图绘制一个颜色花哨的漏斗图
  4. 花旗整合全球财富管理业务
  5. 3.2.3 抽象工厂模式(Abstract Factory) -《SSM深入解析与项目实战》
  6. java radiogroup_Android基础控件RadioGroup使用方法详解
  7. 2022高考那些事——热爱可奔赴山海,抵岁月漫长
  8. HTML position属性
  9. where条件查询语句
  10. assembly.xml