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中创建一个列表时,解释器会在内存中创建一个类似数组的数据结构类存储数据,数据项自下而上堆放(形成一个堆栈).索引从 ...
- python 爬虫系列01-连接mysql
爬虫学习中......................................... import pymysql conn = pymysql.connect(host=',database ...
- tgz 文件解压
使用命令:tar zxvf ×××.tgz 即可进行解压 留作备忘
- (转)Linux 最大进程数
Linux 最大进程数 原文:https://www.cnblogs.com/pangguoping/p/5792075.html 前言 使用环境:centos 7系统 一.查看用户打开的最大进程数 ...
- 第一章:hybrid app开发之技术选型
伴随着移动互联网的兴起,越来越多的企业将部分资源投入其中,想在互联网+的大潮中分一杯羹,并期望着站在风口上,成为时代的弄潮儿. 现在不会做一个app都不好意思说是搞互联网的,那么开发一个app的方式有 ...
- roboframework-ride运行案例时报 Error 267 错误问题
偶然间碰到这个问题,检查下路径是否有中文,如有中文换成英文试试. (ps:通常自己创建的中文路径也是可以的,我的案例是从Linux环境中创建拷贝过来的,可能导致案例路径编码问题)
- 腾讯刘金明:腾讯云 EB 级对象存储架构深度剖析及实践
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 演讲者:刘金明 腾讯云存储业务中心副总监 背景:5月23-24日,以"焕启"为主题的腾讯"云+未来" ...
- 3、card 卡片
1.基本用法的使用 /* --- htm l----*/ <ion-content> <ion-card> <ion-card-header> Header < ...
- Android界面编程--使用活动条(ActionBar)--实现Tab导航
使用ActionBar结合fragment实现导航 1,调用ActionBar的setNavigationModel(ActionBar.NAVIGATION_MODE_TABS)设置使用tabs导航 ...
- PLC总结
PLC编程总结 PLC控制部分总体有三大部分组成,PLC硬件,组态以及梯形图程序.PLC硬件应与组态一一对应,不容有任何偏差:而梯形图与操作的组态的IO口也应该一一对应.因此,整个系统达到了由梯形图程 ...