博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #432 (Div. 2)
阅读量:5972 次
发布时间:2019-06-19

本文共 6069 字,大约阅读时间需要 20 分钟。

A. Arpa and a research in Mexican wave

Arpa is researching the Mexican wave.

There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0.

  • At time 1, the first spectator stands.
  • At time 2, the second spectator stands.
  • ...
  • At time k, the k-th spectator stands.
  • At time k + 1, the (k + 1)-th spectator stands and the first spectator sits.
  • At time k + 2, the (k + 2)-th spectator stands and the second spectator sits.
  • ...
  • At time n, the n-th spectator stands and the (n - k)-th spectator sits.
  • At time n + 1, the (n + 1 - k)-th spectator sits.
  • ...
  • At time n + k, the n-th spectator sits.

Arpa wants to know how many spectators are standing at time t.

Input

The first line contains three integers nkt (1 ≤ n ≤ 109, 1 ≤ k ≤ n1 ≤ t < n + k).

Output

Print single integer: how many spectators are standing at time t.

Examples
input
10 5 3
output
3
input
10 5 7
output
5
input
10 5 12
output
3
Note

In the following a sitting spectator is represented as -, a standing spectator is represented as ^.

  • At t = 0  ----------  number of standing spectators = 0.
  • At t = 1  ^---------  number of standing spectators = 1.
  • At t = 2  ^^--------  number of standing spectators = 2.
  • At t = 3  ^^^-------  number of standing spectators = 3.
  • At t = 4  ^^^^------  number of standing spectators = 4.
  • At t = 5  ^^^^^-----  number of standing spectators = 5.
  • At t = 6  -^^^^^----  number of standing spectators = 5.
  • At t = 7  --^^^^^---  number of standing spectators = 5.
  • At t = 8  ---^^^^^--  number of standing spectators = 5.
  • At t = 9  ----^^^^^-  number of standing spectators = 5.
  • At t = 10 -----^^^^^  number of standing spectators = 5.
  • At t = 11 ------^^^^  number of standing spectators = 4.
  • At t = 12 -------^^^  number of standing spectators = 3.
  • At t = 13 --------^^  number of standing spectators = 2.
  • At t = 14 ---------^  number of standing spectators = 1.
  • At t = 15 ----------  number of standing spectators = 0.

 

题意:给定一种波浪,求每一时刻有多少个站起来了;

#include 
using namespace std;int main(){ int n,k,t; scanf("%d%d%d",&n,&k,&t); if(t<=k) printf("%d\n",t); else if(t<=n) printf("%d\n",k); else if(t<=n+k) printf("%d\n",n-t+k); else puts("0"); t++; return 0;}

 

B. Arpa and an exam about geometry

Arpa is taking a geometry exam. Here is the last problem of the exam.

You are given three points a, b, c.

Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.

Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.

Input

The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct.

Output

Print "Yes" if the problem has a solution, "No" otherwise.

You can print each letter in any case (upper or lower).

Examples
input
0 1 1 1 1 0
output
Yes
input
1 1 0 0 1000 1000
output
No
Note

In the first sample test, rotate the page around (0.5, 0.5) by .

In the second sample test, you can't find any solution.

 

题意:给三个点的坐标a,b,c,看是否经过绕顶点旋转,a 旋转到 b,b到c;

分析:刚开始考虑三个点的外接圆,然后比较圆形角,麻烦了,而且不删除计算几何。

其实,就是 b 到 a,c的距离相等,还要不能在同一条直线上。

距离很好判断,判断三个点是否在同一条直线上,斜率的判定,不能有除以0,于是我转为求余弦,但是结果是long long double 精度都不够,

最好是分类讨论:

#include 
using namespace std;int main(){ long long int ax,ay,bx,by,cx,cy; cin>>ax>>ay>>bx>>by>>cx>>cy; long long int l1 = (by-ay)*(by-ay) + (bx-ax)*(bx-ax); long long int l2 = (cy-by)*(cy-by) + (cx-bx)*(cx-bx); int mark = 0; if( (ax==bx&&ax==cx) || (ay==by&&ay==cy) ) mark = 1; else { double k1 = (by-ay)*1.0/(bx-ax); double k2 = (cy-by)*1.0/(cx-bx); if(k1==k2) mark = 1; } if(mark==1) puts("No"); else if (l1!=l2) puts("No"); else puts("Yes"); return 0;}

 

D. Arpa and a list of numbers

Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty and gcd (see notes section for more information) of numbers in the list is 1.

Arpa can perform two types of operations:

  • Choose a number and delete it with cost x.
  • Choose a number and increase it by 1 with cost y.

Arpa can apply these operations to as many numbers as he wishes, and he is allowed to apply the second operation arbitrarily many times on the same number.

Help Arpa to find the minimum possible cost to make the list good.

Input

First line contains three integers nx and y (1 ≤ n ≤ 5·105, 1 ≤ x, y ≤ 109) — the number of elements in the list and the integers x and y.

Second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the elements of the list.

Output

Print a single integer: the minimum possible cost to make the list good.

Examples
input
4 23 17 1 17 17 16
output
40
input
10 6 2 100 49 71 73 66 96 8 60 41 63
output
10
Note

In example, number 1 must be deleted (with cost 23) and number 16 must increased by 1 (with cost 17).

gcd (greatest common divisor) of a set of numbers is the maximum integer that divides all integers in the set. Read more about gcd .

 

题意:给定一个序列,和 x,y,将这个序列删除任意一个花费 x,将任意一个元素+1花费y;求一些操作以后整个序列的gcd!=1;

分析:

最近数论题做的很少了,没有啥想法,大牛们下了一个定理,什么调和级数一搞,推出这个gcd一定是一个素数。

然后枚举这个10^6里面的素数,我就直接暴力了,稍微剪了一下。

大佬们是求两个区间和,在一定区间内删掉,一定区间内补上,这样的贪心就O(1)内求出花费。

#include 
using namespace std;typedef long long ll;const int maxn = 500005;const int maxnum = 1e6 + 5;int a[maxn];int sum[maxnum];int vis[maxnum];int main(){ int n,x,y; scanf("%d%d%d",&n,&x,&y); for(int i = 0; i < n; i++) { scanf("%d",&a[i]); sum[a[i]] ++; } ll cnt = 0x3f3f3f3f3f3f3f3fll; for(int i = 2; i <= 1000000; i++) { if(!vis[i]) { ll ans = sum[i]; for(int j = 2*i; j<=1000000; j+=i) { vis[j] = 1; ans += sum[j]; } if((n-ans)*min(x,y)

 

转载于:https://www.cnblogs.com/TreeDream/p/7517538.html

你可能感兴趣的文章
SVN: bdb: BDB1538 Program version 5.3 doesn't match environment version 4.7
查看>>
jsp内置对象作业3-application用户注册
查看>>
redis主从配置<转>
查看>>
bootloader功能介绍/时钟初始化设置/串口工作原理/内存工作原理/NandFlash工作原理...
查看>>
Web应用工作原理、动态网页技术
查看>>
EXCEL工作表保护密码破解 宏撤销保护图文教程
查看>>
Catalan数(卡特兰数)
查看>>
python 数据库中文乱码 Excel
查看>>
利用console控制台调试php代码
查看>>
递归算法,如何把list中父子类对象递归成树
查看>>
hdu 1050 (preinitilization or postcleansing, std::fill) ...
查看>>
Linux vmstat命令实战详解
查看>>
我的友情链接
查看>>
替换k个字符后最长重复子串
查看>>
讲解sed用法入门帖子
查看>>
Java异常学习心得
查看>>
Scala学习之类和属性篇(一):定义类的主构造方法
查看>>
使用阿里云CentOS安装LAMP时,安装PHP扩展需要注意的事情
查看>>
Linux 内核已支持苹果
查看>>
shell脚本逻辑判断,文件目录属性判断,if,case用法
查看>>