Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)ABCD
1 second
256 megabytes
standard input
standard output
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>
#define pb push_back
#define ll long long
using namespace std;
const int maxn=1e2+;
int k,t,n;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n>>k>>t;
if(t<=k)
{
cout<<t<<endl;
}
else if(t<=n)
{
cout<<k<<endl;
}
else
{
cout<<k-t+n<<endl;
} return ;
}
2 seconds
256 megabytes
standard input
standard output
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,问你是否可以找一个点d和角度v,把这三个点再围绕d转动v度使得,a在b原来的位置,b在原来的位置。
题解:只要三个点不在一条直线上并且ab==bc,就可以。注意求长度时开方会导致精度出错,所以不开方直接用整数表示。
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int maxn=1e2+;
const double inf=0x3f3f3f3f3f;
const double eps=1e-;
ll ax,ay,bx,by,cx,cy;
ll dis(ll x1,ll y1,ll x2,ll y2 )
{
ll ans;
ans=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
return ans;
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>ax>>ay>>bx>>by>>cx>>cy;
ll tmp1=dis(ax,ay,bx,by);
ll tmp2=dis(bx,by,cx,cy);
double k1=abs(bx-ax)>?double(by-ay)/(bx-ax):inf;
double k2=abs(cx-bx)>?double(cy-by)/(cx-bx):inf;
if(k1==k2)
{
cout<<"NO"<<'\n';return ;
}
if(tmp1==tmp2)
{
cout<<"YES"<<'\n';
}
else
{
cout<<"NO"<<'\n';
}
return ;
}
2 seconds
256 megabytes
standard input
standard output
You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.
We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors and
is acute (i.e. strictly less than
). Otherwise, the point is called good.
The angle between vectors and
in 5-dimensional space is defined as
, where
is the scalar product and
is length of
.
Given the list of points, print the indices of the good points in ascending order.
The first line of input contains a single integer n (1 ≤ n ≤ 103) — the number of points.
The next n lines of input contain five integers ai, bi, ci, di, ei (|ai|, |bi|, |ci|, |di|, |ei| ≤ 103) — the coordinates of the i-th point. All points are distinct.
First, print a single integer k — the number of good points.
Then, print k integers, each on their own line — the indices of the good points in ascending order.
6
0 0 0 0 0
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
1
1
3
0 0 1 2 0
0 0 9 2 0
0 0 5 9 0
0
In the first sample, the first point forms exactly a angle with all other pairs of points, so it is good.
In the second sample, along the cd plane, we can see the points look as follows:
We can see that all angles here are acute, so no points are good.
题意:给你n个五维的点,一个点跟所有其他点构成的向量的角度都是钝角或直角的话则称这个点好。问给的点中有几个好点
题解:暴力判断每个点,(本来以为会被卡没想到过了)
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define PI 3.14159265
using namespace std;
const int maxn=1e3+;
double a[maxn],b[maxn],c[maxn],d[maxn],e[maxn];
int ans[maxn],tmp,n;
struct node
{
double a,b,c,d,e;
};
double dis(node t,node tt)
{
return t.a*tt.a+t.b*tt.b+t.c*tt.c+t.d*tt.d+t.e*tt.e;
}
int slove(node x,node y)
{
double sum=dis(x,y);
double sum1=sqrt(dis(x,x))*sqrt(dis(y,y));
return acos(sum/sum1)*180.0 / PI;
}
void s(int i)
{
for(int j=;j<n;j++)
{
if(j==i)continue;
for(int k=j+;k<=n;k++)
{
if(k==i)continue;
node x,y;
x.a=a[j]-a[i];y.a=a[k]-a[i];
x.b=b[j]-b[i];y.b=b[k]-b[i];
x.c=c[j]-c[i];y.c=c[k]-c[i];
x.d=d[j]-d[i];y.d=d[k]-d[i];
x.e=e[j]-e[i];y.e=e[k]-e[i];
if(slove(x,y)<)
{
return ;
}
}
}
ans[tmp++]=i;
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
for(int i=;i<=n;i++)
{
cin>>a[i]>>b[i]>>c[i]>>d[i]>>e[i];
}
for(int i=;i<=n;i++)
{
s(i);
}
cout<<tmp<<endl;
for(int i=;i<tmp;i++)
{
cout<<ans[i]<<endl;
} }
2 seconds
256 megabytes
standard input
standard output
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.
题意:给n个数,删除一个数花费x,把一个数加一花费y,问使得这n个数的gcd不为1的最小花费。
题解:用vis[]记录,每个数的出现次数,找到2~max(a[1~n])个数之间的所有质数,求出每个质数能把n个数整除的个数然后再根据这个排一下序,再用前面三个质数做为gcd,求出其中的最小值
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define PI 3.14159265
using namespace std;
const int maxn=1e6+;
const ll inf=0xfffffffffffffff;
int a[maxn],n,x,y,maxt;
int vis[maxn];
bool prime[(int)1e6+];
vector<int>p;
bool cmp(int x,int y)
{
return vis[x]!=vis[y]?vis[x]>vis[y]:x<y;
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n>>x>>y;
for(int i=;i<=n;i++)
cin>>a[i],vis[a[i]]++,maxt=max(maxt,a[i]);
bool flag=false;
if(maxt>)flag=true;
for(int i=;i<=min(maxt,maxn-);i++)
{
if(!prime[i])
{
p.pb(i);
for(int j=i*;j<=min(maxt,maxn-);j+=i)prime[j]=true,vis[i]+=vis[j];
}
}
if(!flag)p.pb();
sort(p.begin(),p.end(),cmp);
ll ans=inf;
for(int k=;k<min((int)p.size(),);k++)
{
ll sum=;
for(int i=;i<=n;i++)
{
int t=a[i]%p[k];
if(t)
sum+=min((ll)x,(ll)(p[k]-t)*y);
}
ans=min(ans,sum);
}
cout<<ans<<endl;
}
Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)ABCD的更多相关文章
- 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. 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为上顶点.那么其外接圆圆心即 ...
- Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) D
Arpa has found a list containing n numbers. He calls a list bad if and only if it is not empty and g ...
- Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) C
You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two poi ...
- Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) B
Arpa is taking a geometry exam. Here is the last problem of the exam. You are given three points a, ...
- Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017) A
Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. Th ...
随机推荐
- C++ Concept 和Java 接口
C++ Concept 和Java 接口 Concept及接口 我会用Java写个case来解释什么是C++的Concept.Concept可以理解为接口,它是一种广义的接口.不同于Java的Inte ...
- CSS display使用
.今天我们来分析一下display的一些用法,display样式在我们整个CSS设置中,非常重要,掌握好display,才能有效的解决CSS布局的问题,在理解display之前,我们先了解两个概念:块 ...
- spring mvc:exclude-mapping错误提示
今天搭建一个java web项目时,增加了一个登录的拦截器,主要功能就是未登录的用户无法访问系统的任何页面. 先说明下我的web项目springmvc的版本以及刚开始配置的拦截器: springmvc ...
- H5页面中尝试调起APP
安卓版本5.0以上 IOS版本10.0以上 采用事件触发的方式处理唤醒APP 市面上常见的功能 这种功能现如今应该非常普遍了,淘宝H5,知乎H5等等... 点击后会调起APP或者打开下载页面或者直接进 ...
- Tomcat session生成算法
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt396 修改TOMCAT 默认的生成SESSION ID的算法和字符长度非常简 ...
- Error:Failed to load project configuration:xxxxxxxxxxxxxxxxxxxx cannot read file .idea/misc.xml
你这idea不会没有配置默认jdk吧?你看看File--other settings--default project structure,看看project setting的project里面,有没 ...
- 团队作业4——第一次项目冲刺 FiFtH DaY
项目冲刺--Penta Kill 很开心,小编今天LOL也拿到了五杀,感觉自己又可以去吹一年了. 不扯这些有的没的了,让我们来看看今天的任务吧~ Mission 看起来好像和昨天没有什么不同哦,其实是 ...
- 微信小程序wx.navigateTo层叠5次限制,特殊情况的建议
小程序页面的实例使用栈的数据结构存储,栈内元素最多5个(换一种方式说,就是用户最多能点击5次返回),微信小程序能在栈中相对高层某个页面调用其他相对低层的页面实例的方法. 小程序三种页面跳转API 的区 ...
- 201521123091 《Java程序设计》第1周学习总结
Java 第一周总结 第一周的作业. 1.本章学习总结 [x] 初识Java语言:Java的历史,三大平台,了解JVM/JRE/JDK [x] Java开发环境的配置 [x] 用记事本编写Java程序 ...
- 201521123082《Java程序设计》第2周学习总结
201521123082<Java程序设计>第2周学习总结 标签(空格分隔): Java 1.本周学习总结 巩固了类型转换的相关细节 初步认识了类和对象,使用Java撰写程序几乎都在使用对 ...