题目链接:http://acm.nefu.edu.cn/JudgeOnline/contestShow.php 传送门:nefu

1. Rotate Circle

题面描述:

Rotate Circle

Problem:A

Time Limit:1000ms

Memory Limit:65535K

Description

I know you are very smart and good at math. But how about the analytic geometry. For example, if I give you a compass and you can easily draw a circle of radius R at point P(x, y). However, I can only give you a circle of radius R at point O(x1, y1) now. How to get a circle whose center at P-point and radius is R. We can ensure that P-point and O-point do not overlap. You can only use one kind of operation to make the circle rotate any angle around any point which at the border of the circle. So you can make the circle rotate to P-point by using the circle at O-point after some operation. What is the minimum number of operation to do this .
( operation of rotating around point at border )

Input

There are several test cases.
Each test case contains 5 positive integers R , x , y , x1 , y1 as the description in one line. ( R ≤ 1000 , 0 ≤ x ,y ≤100,000,000 and 0 ≤ x1 , y1 ≤ 100,000,000 ).
The input will finish with the end of file.

Output

For each the case, your program will output one positive integers indicate the answer.

Sample Input

5 47 72 97 8
4 44 38 32 79

Sample Output

9
6

题目大意:

如果说我们有圆规的话,我们很容易就能画出一个已知半径和圆心的圆,但是我们现在只有一个已知其圆心O和半径R的圆所以我们通过绕圆边界上任意一点旋转任意角度的方法,得到一个圆心在点P且半径为R的圆,求最少需要进行旋转的次数。

题目分析:

为了使旋转的次数最少,我们需要沿着OP连线的方向以最大长度进行旋转,即最大长度就是圆的直径,对于最后一次旋转就要比较用心一点,绕着一个点旋转一个合适的角度,恰好可以使圆心落在P点即可。所以需要进行移动的次数就等于|OP|/R向下取整在加1.

代码实现:

#include <iostream>
#include <cstdio>
#include <cmath>using namespace std;int main()
{long long x,y,x1,y1;int r;long long num=0;while(scanf("%d%lld%lld%lld%lld",&r,&x,&y,&x1,&y1)!=EOF){long long d=(long long)sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));num=(long long)d/(2*r);printf("%lld\n",num+1);}return 0;
}

2. Cut The Cake:

题面:

Cut The Cake

Problem:F

Time Limit:1000ms

Memory Limit:65535K

Description

Today is Julia's birthday, she was so delightful that she decided to buy a big cake and celebrate with her friends. The cake is circular in shape. Now a total of n people will eat the cake, so Julia cut the cake equally into n shares. But m persons say they want to eat the cake too. So now there are n + m people want to eat the cake. Please answer, how many times at least can Julia cut n pieces of cakes equally into n+m pieces? (Julia can only cut from the center of the circle to circumference, put several pieces of cakes together can be seen as one piece)

Input

a number t will be input on the first line, then t lines will be follow.
Each line will contain two integers n and m.
1&lt;=t &lt;=10000, 1&lt;=n,m&lt;=1000

Output

For each case, output the minimum times of cut in one line.

Sample Input

2
2 1
3 1

Sample Output

2
3

题目大意:

蛋糕需要平均分,一开始有n个人,后来又来了m个人,问从n个人到n+m个人还需要再切几刀蛋糕。

题目分析:

我们规定,从蛋糕圆心到蛋糕边缘的半径为一刀,且一个人的时候我们也把蛋糕切了一刀,且这一刀并没有把蛋糕分开。找规律,通过需要均分的度数来确定需要的刀数,比如,原来有6个人(60度一块),又来了9个人(40度一块),可以重复的刀数为120度,240度,360度(0度),所以需要切的刀数为6+9-gcd(6,9)。所以,此题所需刀数为m+n-gcd(m,n)。

代码实现:

#include <iostream>using namespace std;
int gcd(int a,int b)
{if(!b)return a;elsereturn gcd(b,a%b);
}
int main()
{int t;int n,m;cin>>t;while(t--){cin>>n>>m;m=m+n;if(m%n==0)cout<<m-n<<endl;else{if (gcd(m,n)==1)cout<<m-1<<endl;elsecout<<m-gcd(m,n)<<endl;}}return 0;
}

3.Lazy People:

题面:

Lazy People

Problem:I

Time Limit:1000ms

Memory Limit:65535K

Description

On a flat map, there are n straight lines ,which divide the map into many regions, two regionsare adjacent if and only if they have a common boundary edges. Walk from one region to its adjacent region cost exactly only one unit of energy.You can’t walk from one to another if this two regions is not adjacent.
SmallSmallBule's home is on Point P. Every day,he needs to go to school which is located at Point Q, P and Q are located in different regions. Since SmallSmallBlue is very lazy,he wants to know what is the minimum units of  energy to be  cost to go to school from home. Now,he needs your help to calculate the answer.

Input

the first line has a number T,(T&lt;=22),which is the number of testcases.
for each testcase,the first line has two integers xs,ys(-10^6&lt;=xs,ys&lt;=10^6),,which is the  location of SmallSmall blue's home.
the second line has two integers xh,yh(-10^6&lt;=xh,yh&lt;=10^6),which is the location of school.
the third line has a number n(n&lt;=400),which is the number of straight lines. then the next n lines,each line has three integers,ai,bi,ci,(-10^6&lt;=ai,bi,ci&lt;=10^6) which are to represent the straight line ai*x+bi*y+c=0.

Output

for each testcase,you need to output one line which contains only one integer,
which is the minimum units of energy to be cost to go from home to school.

Sample Input

2
2 2
-2 -2
2
0 2 0
2 0 03 3
-3 -3
3
0 2 0
1 0 1
1 0 -1

Sample Output

2
3

Hint

In the first test case,two lines is x=0 and y=0, home is (2,2), school is (-2,-2), so he needs to use up 2 units of energy.(he uses up first unit of energy by arriving at the first region which (-1,1) or (1,-1) belongs to, and uses up second unit of energy by arriving at the second region which the school belongs to)

题目大意:

已知家的坐标和学校的坐标,还有n条直线,可以把整个二维直角坐标系划分成多个部分,每跨一次区域都会消耗一格能量,求最少消耗的能量数。

题目分析:

判断家和学校这条线段和n条直线的交点个数即可,判断方法即为把两个点的坐标带入直线方程中去,如果两个值相乘==0,则说明存在一个在直线上的点,若结果<0,则说明两点在直线两侧,若结果>0,则说明两点在直线同侧。

特别注意:此题注意数据范围,由于方程系数和坐标点的范围都是10^6以内,但是把点带入坐标以后得到的就是一个long long类型才能存的下的数了,所以我们必须在long long范围内进行数据计算,否则会WA的。

代码实现:

#include <iostream>
#include <cstdio>
#include <cstring>using namespace std;long long a[420],b[420],c[420];
int main()
{long long T;long long xs,ys,xh,yh;long long n;scanf("%lld",&T);memset(a,0,sizeof(a));memset(b,0,sizeof(b));memset(c,0,sizeof(c));while(T--){scanf("%lld%lld%lld%lld",&xs,&ys,&xh,&yh);scanf("%lld",&n);memset(a,0,sizeof(a));memset(b,0,sizeof(b));memset(c,0,sizeof(c));for(int i=0;i<n;i++){scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);}int num=0;for(int i=0;i<n;i++){if(((a[i]*xs+b[i]*ys+c[i])*(a[i]*xh+b[i]*yh+c[i]))<0){num++;}}printf("%d\n",num);}return 0;
}

4. Max a&b:

Max a&b

Problem:B

Time Limit:3000ms

Memory Limit:65536K

Description

Now give you n positive integers. You can select two integers from n integers, and calucate the (a&amp;b). ‘&amp;’ is a binary operator.For example, 5&amp;6=4.
Now I need you calculate the maximum value of (a&amp;b).

Input

There are multiple test cases.
For each test case.The first line contains one integer n(n&lt;=300000), which indicates the number of integers.
The following n lines. The ith line contains one positive integer ai.(ai&lt;=10^9)

Output

For each test case, your program will output the maximum value of a&amp;b.

Sample Input

3
2
8
10

Sample Output

8

题目大意:

给出n个数,求任意两个数相与的最大值。

题目分析:

按从高位到地位的贪心来处理即可,此题数据比较水,这个代码不是很强壮,如:若两个最大数的&为0的话,代码没有输出,但是能过,不幸中的万幸了。当然还有待改进,具体思路就是,先排序,然后再从最大的开始处理,把每个数的二进制位数记录下来,(由于数据为10^9即为2^30次方左右,所以不会超时)如果最大的两个数二进制位数相同,则经过&操作后,必然有所得结果最大;如果两个最大数的位数不相等,那么经过&操作之后所得结果的位数就不一定是多少位了,所以要和倒数第二个和倒数第三个这两个数的&之后的结果进行比较,不但要比较位数,还要比较结果,这样以此类推下去。

代码实现:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>using namespace std;long long a[300010];
int bit[300010];
int main()
{int n;long long maxx,t;int b;long long x;int xb;while(scanf("%d",&n)!=EOF){memset(a,0,sizeof(a));memset(bit,0,sizeof(bit));for(int i=0; i<n; i++){scanf("%lld",&a[i]);}//cout<<"dsyhfg"<<endl;sort(a,a+n);for(int i=0;i<n;i++){t=a[i];while(t>0){t/=2;bit[i]++;}}for(int i=n-1; i>=0; i--){if(bit[i]==bit[i-1]){printf("%lld\n",a[i]&a[i-1]);break;}else{maxx=a[i]&a[i-1];b=0;t=maxx;while(t>0){t/=2;b++;}x=a[i-1]&a[i-2];t=x;xb=0;while(t>0){t/=2;xb++;}if(b>xb){//cout<<"111hdgfj"<<endl;printf("%lld\n",maxx);break;}else if(b==bit[n-2]){//cout<<"222hdgfj"<<endl;if(x>maxx){maxx=x;b=xb;}}else if(b<bit[n-2]){//cout<<"333hdgfj"<<endl;maxx=x;b=xb;}}}}return 0;
}

周末来一发之五一周赛相关推荐

  1. 2016年下半年总结(连载)!

    2016年下半年总结(连载!) ①   10月总结 夜深人静的时候.一个的时候总喜欢多想.    这一个月真是过得快啊,不免又说起了老套而又真实的话.此刻:2016/10/29/23:34.    开 ...

  2. 大学生毕业摆地摊月入两万的真实经历

    2018年3月12号开始做这个号,5月份见了一个投资人,从晚上8点聊到凌晨,其中大概有三分之一的时间在聊"我大学毕业之后在北京摆地摊的经历". 聊完,他还是好奇加不解的问: &qu ...

  3. 意大利归还中国文物;翟天临咪蒙成考公务员题目;携程回应五一机票涨价;腾讯未成年人网络保护体系上线;这就是今天的大新闻...

    今天是3月25日 农历二月十九 今天星期一 整个周末都贡献给都挺好了 下面是今天的大新闻 意大利归还796件中国文物 (新京报)3月23日,在中国主席和意大利总理孔特共同见证下,中意双方代表交换关于7 ...

  4. mysql 节假日判断_sql 节假日判断(春节、中秋、国庆、周末等)

    set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- 日期检测函数,返回相关节假日 -- 0 非假日 -- 农历相关假日 -- 1 春节(正月初一 至 正月 ...

  5. sql 节假日判断(春节、中秋、国庆、周末等)

    set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- 日期检测函数,返回相关节假日 -- 0 非假日 -- 农历相关假日 -- 1 春节(正月初一 至 正月 ...

  6. 为了庆祝五一国际劳动节的到来

    为了庆祝五一国际劳动节的到来 我郑重决定,为CMCC免费加班一天! 为了即将到来的长假,许多双休的同志们也在周末照常上班.对于我来说,5/1-5/7,这一周并不带什么特殊的颜色(黄金周). 也许是因为 ...

  7. SQL计算两个日期之间的工作日天数,去除法定节假日和周末

    项目要求:需要计算两个日期之间的工作日天数,包含元旦.五一.十一等法定假日. 网上查询很多SQL函数,最终发现都不太理想,例如国庆放假可能会调休,周末也要上班.所以唯一的解决方案是建立一张工作日时间表 ...

  8. 拼多多被曝确定五一放假三天,网友:“这也砍一刀?”

    眼看着五一马上来临,即将喜提"五天"小长假的消息,让无数打工人欢呼雀跃. 然而,大家的快乐似乎并不相通. 有知情人士在脉脉上爆料,4 月 26 日晚上拼多多内部终于敲定了今年五一的 ...

  9. 五一劳动节 甩开压力“嗨”起来

    " 劳动人民最光荣,阿D服务永不休".首先预祝大家有一个愉快的五一,阿D五一假期放假安排如下: 放假时间:2015年5月1日-5月3日,共3天:5月4日正常上班. 放假期间,为了保 ...

最新文章

  1. 定位的四个点怎么打_别被忽悠了,轮胎动平衡和四轮定位一定要区分清楚
  2. 在Ubuntu中永久添加DNS
  3. HTML显示xml中的CDATA内容
  4. 自动装箱自动拆箱java,自动装箱?拆箱?==问题?详解java面试常见的一个问题...
  5. java中怎样验证重复文件_java – 如何在下载之前检查URL中的重复文件
  6. go定时器 每天重复_Go语言学习基础-定时器、计时器
  7. 1.0 Hadoop的介绍、搭建、环境
  8. React Native App设置amp;Android版发布
  9. spring源码分析第四天------springmvc核心原理及源码分析
  10. 【软件工程】实体类的持久性
  11. 克罗地亚第二狂想曲难度_黄海保级难度增加,将送强力前锋去富力,与建业竞争半个降级名额...
  12. java并发测试 线程池,Java并发编程——线程池
  13. 无法检测的新型 Linux 恶意软件利用 Dogecoin API 攻击 Docker 服务器
  14. XTU-oj 字符矩阵
  15. 赛门铁克symantec的安装与卸载-附下载地址(本人亲测)
  16. Xbrowser远程RHEL5.5
  17. 作为一个才刚刚开始学习java的小白 居然显示码龄3年??每天吃饭点菜成为了一个难题 然后今天简单写了一个随机菜单
  18. Linux_标准IO
  19. ios 在window和mac上另类打包方式
  20. Kafka 压缩、限流和 SASL_PLAIN 、 SASL_SCRAM-SHA-256简单认证

热门文章

  1. java实现蔬菜版的大富翁游戏~~~
  2. android属性动画不流畅,Android动画之属性动画
  3. 设计模式的五大原则(二)
  4. 【链接】免费资源(电影)
  5. 纯CSS代码写出各种不规则的形状图形
  6. 连闯三关的概率是多少
  7. 大学小学期实践课程第六课:车辆动力学标定
  8. 数据透视表——pivot_table学习(特征工程)
  9. 生存游戏计算机,文字生存游戏
  10. Centos7离线ag搜索工具the_silver_searcher(未完待续)