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 vectori+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 x bead(s), CC” instead.

Your output format should imitate the sample output. Print a blank line after each test case.

样例输入

3
1 1
2 2
3 33
1 1
2 2
1 14
1 1
2 2
3 3
2 20

样例输出

C
CC
Remove 1 bead(s), C

http://hsacm.cn/JudgeOnline/problem.php?id=1437

咋一看这道题目以为是几何难题,其实很水的。。。

题意:给出n个点的坐标,相邻的点组成一条向量,从i指向i+1,问最少删掉几个点可以使剩下点组成的向量都指向顺时针或都指向逆时针。

#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<set>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
int n;
struct node{int a,b;
};
node x[301];
int y[301][301];
int isok(int i,int j,int k){int x1=x[i].a-x[j].a;int y1=x[i].b-x[j].b;int x2=x[j].a-x[k].a;int y2=x[j].b-x[k].b;if(x1*y2==x2*y1){    //两条向量共线要特殊判断(同向和反向)if (min(x1,x2)<=0&&max(x1,x2)>=0&&min(y1,y2)<=0&&max(y1,y2)>=0)  return 0;elsereturn 1;}if (x1*y2-x2*y1>0)  //1在2的右边return true;  return false;       //1在2的左边
}
int main(){while(scanf("%d",&n)&&n!=0){for(int i=0;i<n;++i){scanf("%d %d",&x[i].a,&x[i].b);}int s1=0,s2=0;memset(y,0,sizeof(y));for(int i=0;i<n;++i){for(int j=0;j<i;++j)y[j][i]=1;}for(int i=0;i<n;++i){  //枚举i+1for(int j=0;j<i;++j){  //枚举 ifor(int k=0;k<j;++k){  //枚举i-1if(isok(i,j,k))  //顺时针y[j][i]=max(y[j][i],y[k][j]+1);if(y[j][i]>s1)s1=y[j][i];}}}memset(y,0,sizeof(y));for(int i=0;i<n;++i){for(int j=0;j<i;++j)y[j][i]=1;}for(int i=0;i<n;++i){for(int j=0;j<i;++j){for(int k=0;k<j;++k){if(!isok(i,j,k))  //逆时针y[j][i]=max(y[j][i],y[k][j]+1);if(y[j][i]>s2)s2=y[j][i];}}}if(s1==n-1)printf("C\n");else if(s2==n-1)printf("CC\n");  else{if(s1>=s2)printf("Remove %d bead(s), C\n",n-1-s1);  elseprintf("Remove %d bead(s), CC\n",n-1-s2);  }  printf("\n");}return 0;
}

hznu 1437: Clockwise(隐藏的暴力水题,数学)相关推荐

  1. HDU - 4737 A Bit Fun 暴力水题

    题目大意:给出n个数,要求找出符合 f(i, j) = a i|a i+1|a i+2| - | a j . Where "|" is the bit-OR operation. ...

  2. 2021汤家凤1800题数学一PDF_【重要更新】朱伟9720年英语一二真题解析视频 唐迟罗汉班 谭剑波作文 新东方英语 文都数学汤家凤...

      帮主 呜呜呜~找不到考研资料怎么办 小帮帮 将法硕帮设为星标,置顶公众号,每日更新不再错过! 法硕帮所有成员均为考研上岸学生 你所困惑的正是我们曾经经历过的 公众号所有资料均来自网络搜集整理 你们 ...

  3. 2019李永乐660题 数学二-题目

    2019李永乐660题 数学二-题目 链接: https://pan.baidu.com/s/18yDi-HIbn5LLRmBn4cNWCQ 提取码: f7yk 复制这段内容后打开百度网盘手机App, ...

  4. 2019李永乐660题 数学二-答案

    2019李永乐660题 数学二-答案 链接: https://pan.baidu.com/s/1CmjRNEiZQBiBeBe14woHzQ 提取码: 858v 复制这段内容后打开百度网盘手机App, ...

  5. 2019原创考研数学 基础过关660题 数学一

    2019原创考研数学 基础过关660题 数学一 链接: https://pan.baidu.com/s/1U5SLSQpRRlNu80stqkh6uw 提取码: fw68 复制这段内容后打开百度网盘手 ...

  6. 2019李永乐考研数学 基础过关660题 数学一

    2019李永乐考研数学 基础过关660题 数学一 链接: https://pan.baidu.com/s/1r2jyBI-i1u_uA3fCLnZsEg 提取码: 5ubf 复制这段内容后打开百度网盘 ...

  7. 交大网络11秋计算机高起专一共要考几门,2010年秋季西南交大高起专网络教育入学考试模拟题数学...

    西南交通大学网络教育入学考试模拟题 数学(一) 1.下列命题正确的是( C ) A. {实数集} B. {|x x ?≤ C. {|x x ≤ D. {|x x ?≤ 2.终边在y 轴的正半轴上的角的 ...

  8. C#LeetCode刷题-数学

    数学篇 # 题名 刷题 通过率 难度 2 两数相加 29.0% 中等 7 反转整数 C#LeetCode刷题之#7-反转整数(Reverse Integer) 28.6% 简单 8 字符串转整数 (a ...

  9. 每日一题 | 数学神童的红眼睛与蓝眼睛问题

    点击上方"五分钟学算法",选择"星标"公众号 重磅干货,第一时间送达 大家好,这是一个全新的专题,设立的初衷是分享一些我觉得比较有趣的算法题或者是各类问题.帮助 ...

最新文章

  1. 月入5W,月花销不足2K的程序员,可免费获得AI女友一名
  2. Kafka 2.8.0发布,与ZooKeeper正式分手!
  3. ubuntu17.04下mysql5.7.18源码安装
  4. 原生js写三级联动 java_原生js三级联动的简单实现代码
  5. ios开发中的C语言学习—— 结构体简介
  6. Shrio 自定义算法登录认证
  7. boost::statechart模块测量 BitMachine 的事件处理性能的测试程序
  8. java当中各种流的应用场景_Java中有哪些流,常用流有哪些并有何特点和使用场景 NIO流,特性及使用时注意的事项 IO与NIO区别...
  9. jquery 获取键值对中最大值_jquery属性的操作
  10. Android 8.0学习(27)--- SystemUI(二)启动流程和初始化
  11. 最美旗舰机型又将易主?三星Galaxy S11高清渲染图曝光
  12. 宿命传说2之女神召唤java_【更新公告】新SSR装备召唤概率限时UP!梅林领悟了全新助战技!...
  13. intro是啥意思_Intro是什么意思?
  14. 【美港探案】百度Q2:需要重新定义
  15. Windows电脑快捷键
  16. java面试常问问题及答案,附源代码
  17. Android手机QQ的UI自动化实践,为什么spring能最好地改变Android
  18. CTS Verifier NFC Test
  19. MacOS 上安装 telnet 和 wget
  20. 【U8】填制凭证输入完摘要,回车后报错运行时错误70,拒绝的权限。

热门文章

  1. 开源、云、传统IT的三国杀
  2. UPD简单的数据发送
  3. 34、基于51单片机锂电池电压电流容量检测仪表LCD液晶显示 原理图PCB程序设计
  4. linux卸载命令6,小编为你叙述linux卸载命令【操作流程】
  5. 单个进程降低cpu占用的方法
  6. nofile和noproc
  7. zookeeper启动遇到No such file or directory
  8. Chrome浏览器安装后,无法正确访问网址
  9. Arduino监控和可视化心率脉搏
  10. java取出字符串中的后四位_[原]Java面试题-将字符串中数字提取出来排序后输出...