A. Arpa and a research in Mexican wave
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

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>
#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 ;
}
B. Arpa and an exam about geometry
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

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,问你是否可以找一个点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 ;
}
C. Five Dimensional Points
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

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.

Examples
input
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
output
1
1
input
3
0 0 1 2 0
0 0 9 2 0
0 0 5 9 0
output
0
Note

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;
} }
D. Arpa and a list of numbers
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

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.

题意:给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的更多相关文章

  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. 1, based on IndiaHacks Final Round 2017) D. Tournament Construction(dp + 构造)

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

  3. 【前缀和】【枚举倍数】 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 ...

  4. 【推导】【暴力】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个点,那么再往里面添加任意多个 ...

  5. 【推导】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为上顶点.那么其外接圆圆心即 ...

  6. 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 ...

  7. 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 ...

  8. 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,  ...

  9. 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 ...

随机推荐

  1. final关键字的使用

    public class FinalDome extends Final{ private final double PI = 3.1415926;//常量,不可改变 private int num ...

  2. Redis基本数据类型

    -------------------Redis基本数据类型------------------- 1.String 字符串     1.概念         1.String 是redis最基本的类 ...

  3. 编译make的出错提示解决方案

    编译出错笔记:start.s:20: Error: no such instruction: `ldr r0,=WTCON' 错误:没有这样的指令 解决:编译文件后缀名必须为大写S,改为start.S ...

  4. 没有闲话和grunt.initConfig()

    grunt.initConfig()为Gruntfile.js的核心部分,它接收对象作为参数. 对象包含两种类型的属性,一种是单纯的变量,一种是task类型.举个栗子: grunt.initConfi ...

  5. 图论中DFS与BFS的区别、用法、详解?

    DFS与BFS的区别.用法.详解? 写在最前的三点: 1.所谓图的遍历就是按照某种次序访问图的每一顶点一次仅且一次. 2.实现bfs和dfs都需要解决的一个问题就是如何存储图.一般有两种方法:邻接矩阵 ...

  6. 团队作业4——第一次项目冲刺(Alpha版本) 2

    一.Daily Scrum Meeting照片 二.燃尽图 三.项目进展 1.完成了大部分查重算法的书写. 余弦查重算法 2.其他非主页面的部分设计. 查重过程的显示页面 四.困难与问题 1.算法是程 ...

  7. 201521123072《java程序设计》第八周总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 2. 书面作业 List中指定元素的删除(题目4-1) 1.1 实验总结 在删除List中的元素中要考虑元素删 ...

  8. 201521123073《Java程序设计》第4周学习总结

    一. 本周学习总结 二. 书面作业 1.注释的应用 2.面向对象设计(大作业1,非常重要) 2.1 将在网上商城购物或者在班级博客进行学习这一过程,描述成一个故事.(不得少于50字,参考QQ群中PPT ...

  9. 201521123112《Java程序设计》第2周学习总结

    1.本周学习总结 本周在课堂面授课粗略讲了<Java学习笔记>中的第三章,其内容大部分都与上学期学习的数据结构差不多,所以只是粗略的复习了一下就带过,然后通过将PTA上的实验便于我们本周的 ...

  10. 201521123003《Java程序设计》第9周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 2. 书面作业 本次PTA作业题集异常 1.常用异常 题目5-1 1.1 截图你的提交结果(出现学号) 1.2 自己 ...