Codeforces Round #432 (Div. 2)
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.
The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).
Print single integer: how many spectators are standing at time t.
10 5 3
3
10 5 7
5
10 5 12
3
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 ;
}
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.
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.
Print "Yes" if the problem has a solution, "No" otherwise.
You can print each letter in any case (upper or lower).
0 1 1 1 1 0
Yes
1 1 0 0 1000 1000
No
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 ;
}
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.
First line contains three integers n, x 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.
Print a single integer: the minimum possible cost to make the list good.
4 23 17
1 17 17 16
40
10 6 2
100 49 71 73 66 96 8 60 41 63
10
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)的更多相关文章
- 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> # ...
- 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 ...
- Codeforces Round #432 Div. 1 C. Arpa and a game with Mojtaba
首先容易想到,每种素数是独立的,相互sg就行了 对于一种素数来说,按照的朴素的mex没法做... 所以题解的简化就是数位化 多个数同时含有的满参数因子由于在博弈中一同变化的,让他们等于相当于,那么这样 ...
- Codeforces Round #432 (Div. 1) B. Arpa and a list of numbers
qtmd的复习pat,老子不想看了,还不如练几道cf 这题首先可以很容易想到讨论最后的共因子为素数 这个素数太多了,1-1e6之间的素数 复杂度爆炸 所以使用了前缀和,对于每个素数k的每个小区间 (k ...
- Codeforces Round #432 Div. 1
A:大胆猜想合法点不会很多,于是暴力检验,一旦发现不合法就break,可以random_shuffle一下. #include<iostream> #include<cstdio&g ...
- Codeforces Round #432 (Div. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)
题意 一个竞赛图的度数集合是由该竞赛图中每个点的出度所构成的集合. 现给定一个 \(m\) 个元素的集合,第 \(i\) 个元素是 \(a_i\) .(此处集合已经去重) 判断其是否是一个竞赛图的度数 ...
- 【前缀和】【枚举倍数】 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 ...
- 【推导】【暴力】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个点,那么再往里面添加任意多个 ...
- 【推导】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为上顶点.那么其外接圆圆心即 ...
随机推荐
- python 学习笔记二_列表
python不需要声明类型信息,因为Python的变量标识符没有类型. 在Python中创建一个列表时,解释器会在内存中创建一个类似数组的数据结构类存储数据,数据项自下而上堆放(形成一个堆栈).索引从 ...
- javascript中构造函数与普通函数的区别还有关于“new”操作符的一些原理
有一种创建对象的方法叫做工厂模式,例如: function person(name,age){ var o=new Object(); o.name=name; o.age=age; return o ...
- webstorm 搜索vue文件
1. Show IDE settings 状态修改为 ON
- IBM Rational Appscan Part 1
By Rohit T|July 23rd, 2012 http://resources.infosecinstitute.com/ibm-rational-appscan/ IBM Rational ...
- BNU7538——Clickomania——————【区间dp】
Clickomania Time Limit: 10000ms Memory Limit: 32768KB 64-bit integer IO format: %I64d Java clas ...
- 【转】常用的邮箱服务器(SMTP、POP3)地址、端口
gmail(google.com)POP3服务器地址:pop.gmail.com(SSL启用 端口:995)SMTP服务器地址:smtp.gmail.com(SSL启用 端口:587) 21cn.co ...
- 初学Hadoop之中文词频统计
1.安装eclipse 准备 eclipse-dsl-luna-SR2-linux-gtk-x86_64.tar.gz 安装 1.解压文件. 2.创建图标. ln -s /opt/eclipse/ec ...
- git pull冲突报错
修改代码后在git pull报错: error: Your local changes to the following files would be overwritten by merge: xx ...
- mysql多表条件更新
有两张表bas_student.bas_householder, 去除学生表中与家长表重复的手机号 UPDATE bas_student a,bas_householder b SET a.mobil ...
- Introduction of Servlet Filter(了解Servlet之Filter)
API文档中介绍了public Interface Filter(公共接口过滤器) Servlet API文档中是这样介绍的: ‘A filter is an object that performs ...