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 ≤ n, 1 ≤ 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 <bits/stdc++.h>

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("");
t++; return ;
}
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 <bits/stdc++.h>

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 = ; if( (ax==bx&&ax==cx) || (ay==by&&ay==cy) )
mark = ;
else {
double k1 = (by-ay)*1.0/(bx-ax);
double k2 = (cy-by)*1.0/(cx-bx); if(k1==k2)
mark = ;
} if(mark==)
puts("No");
else if (l1!=l2)
puts("No");
else puts("Yes"); return ;
}
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).

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

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

分析:

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

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

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = ;
const int maxnum = 1e6 + ; 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 = ; i < n; i++) {
scanf("%d",&a[i]);
sum[a[i]] ++;
} ll cnt = 0x3f3f3f3f3f3f3f3fll; for(int i = ; i <= ; i++) {
if(!vis[i]) {
ll ans = sum[i]; for(int j = *i; j<=; j+=i) {
vis[j] = ;
ans += sum[j];
} if((n-ans)*min(x,y)<cnt) {
ll tans = ;
for(int j = ; j<n; j++) {
if(a[j]%i) {
ll t = a[j]%i;
tans += min((ll)*x,(ll)*y*(i-t));
}
}
cnt = min(cnt,tans);
}
}
} printf("%lld\n",cnt); return ;
}

Codeforces Round #432 (Div. 2)的更多相关文章

  1. D. Arpa and a list of numbers Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)

    http://codeforces.com/contest/851/problem/D 分区间操作 #include <cstdio> #include <cstdlib> # ...

  2. Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)ABCD

    A. Arpa and a research in Mexican wave time limit per test 1 second memory limit per test 256 megaby ...

  3. Codeforces Round #432 Div. 1 C. Arpa and a game with Mojtaba

    首先容易想到,每种素数是独立的,相互sg就行了 对于一种素数来说,按照的朴素的mex没法做... 所以题解的简化就是数位化 多个数同时含有的满参数因子由于在博弈中一同变化的,让他们等于相当于,那么这样 ...

  4. Codeforces Round #432 (Div. 1) B. Arpa and a list of numbers

    qtmd的复习pat,老子不想看了,还不如练几道cf 这题首先可以很容易想到讨论最后的共因子为素数 这个素数太多了,1-1e6之间的素数 复杂度爆炸 所以使用了前缀和,对于每个素数k的每个小区间 (k ...

  5. Codeforces Round #432 Div. 1

    A:大胆猜想合法点不会很多,于是暴力检验,一旦发现不合法就break,可以random_shuffle一下. #include<iostream> #include<cstdio&g ...

  6. Codeforces Round #432 (Div. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)

    题意 一个竞赛图的度数集合是由该竞赛图中每个点的出度所构成的集合. 现给定一个 \(m\) 个元素的集合,第 \(i\) 个元素是 \(a_i\) .(此处集合已经去重) 判断其是否是一个竞赛图的度数 ...

  7. 【前缀和】【枚举倍数】 Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D. Arpa and a list of numbers

    题意:给你n个数,一次操作可以选一个数delete,代价为x:或者选一个数+1,代价y.你可以进行这两种操作任意次,让你在最小的代价下,使得所有数的GCD不为1(如果全删光也视作合法). 我们从1到m ...

  8. 【推导】【暴力】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) C. Five Dimensional Points

    题意:给你五维空间内n个点,问你有多少个点不是坏点. 坏点定义:如果对于某个点A,存在点B,C,使得角BAC为锐角,那么A是坏点. 结论:如果n维空间内已经存在2*n+1个点,那么再往里面添加任意多个 ...

  9. 【推导】Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) B. Arpa and an exam about geometry

    题意:给你平面上3个不同的点A,B,C,问你能否通过找到一个旋转中心,使得平面绕该点旋转任意角度后,A到原先B的位置,B到原先C的位置. 只要A,B,C构成等腰三角形,且B为上顶点.那么其外接圆圆心即 ...

随机推荐

  1. gulp打包js

    在终端定位到你要创建目录的地方,输入 sudo mkdir js 创建文件夹,这个文件夹就是放你要压缩js文件的地方 输入 sudo vim gulpfile.js 这个js就是写gulp所有的配置信 ...

  2. spark第十八篇:Tuning Spark 调优

    由于大多数Spark应用都是在内存中计算的,所以,Spark程序的瓶颈可能是集群中的任何资源,比如CPU,网络带宽或者内存等.本指南主要涵盖两个主题: 1.数据序列化.这对于良好的网络性能至关重要,还 ...

  3. python-几种快速了解函数及模块功能的方式

    背景 在进行编程的时候经常要导入各种包的各种函数,但是很多包一下又不知道为什么要导入这个模块,所以想总结下有哪些方法可以让我们快速熟悉其中函数的作用. import numpy as np impor ...

  4. zTree 图标样式

    <link rel="stylesheet" href="jquery/ztree/css/zTreeStyle/zTreeStyle.css" /> ...

  5. Oracle 过程中变量赋值

    create or replace function get_sal1(id employees.employee_id%type) return number is sal employees.sa ...

  6. 关于EF更新数据库,更新指定字段的设置

    1.关于EF跟新数据库更新指定字段的设置 在EF提交到数据库的时候或许某些字段不想更新.或者自己更新一个模型到数据库去! 1.更新数据不更新一些字段 /// <summary> /// 数 ...

  7. Quartz使用及注意事项

    Quartz使用及注意事项 前提:目前由于公司业务决定,大量使用Quartz,每天固定的时间点执行相应的业务逻辑,,几十个时间点应该是有的,某一个时间点如果没有执行带来的问题是巨大的.Quartz的稳 ...

  8. dubbo-admin网页管理控制台

    由于近段时间在看dubbo,网上找到的这个war包发布到tomcat报错,故从git(https://github.com/apache/incubator-dubbo-ops)上重新下载编译了版本 ...

  9. Stage1--Python的特点和安装

    说在前面: Stage1-Stage4简单介绍一下Python语法,Stage5开始用python实现一些实际应用,语法的东西到处可以查看到,学习一门程序语言的最终目的是应用,而不是学习语法,语法本事 ...

  10. eclipse中手动设置library,选择编译工具方法

    target=android-25sdk.buildtools=25.0.2 target=android-26android.library=falseandroid.library.referen ...