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. python---统计列表中数字出现的次数

    import collections a = [1,2,3,1,2,3,4,1,2,5,4,6,7,7,8,9,6,2,23,4,2,1,5,6,7,8,2] b = collections.Coun ...

  2. app端性能测试笔记

     IOS不清楚,我就说说android平台吧 1.按不同维度  APP级性能.代码级性能      app这一级   GT啊  emmage都可以检测 2.代码级性能的话  有可以分几块 函数性能UI ...

  3. 【详细资料】ICN6211:MIPI DSI转RGB芯片简介

    ICN6211功能MIPI DSI转RGB,分辨率1920*1200,封装QFN48

  4. C#输出杨辉三角形

    话不多说直接上代码: class Program { static void Main(string[] args) { ;//杨辉三角形的长度 Console.Write("输入杨辉三角长 ...

  5. Maven生成可以直接运行的jar包的多种方式

    Maven可以使用mvn package指令对项目进行打包,如果使用Java -jar xxx.jar执行运行jar文件,会出现"no main manifest attribute, in ...

  6. 大型网站的 HTTPS 实践(三)——基于协议和配置的优化

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt389 1 前言 上文讲到 HTTPS 对用户访问速度的影响. 本文就为大家介 ...

  7. C#大量数据导出到Excel(转)

    工作过程中经常会用到将数据导出到Excel中,一般情况下需要导出的数据都是几百几千条或者上万条,这都没有什么问题,但有时候会遇到特殊的需求,客户要求把几十万条甚至上百万条的数据导出到Excel中,这就 ...

  8. c# 读取excel数据的两种方法(转)

    转载自:http://developer.51cto.com/art/201302/380622.htm, 方法一:OleDb: 用这种方法读取Excel速度还是非常的快的,但这种方式读取数据的时候不 ...

  9. 协处理器CP15介绍—MCR/MRC指令(6)

    概述:在基于ARM的嵌入式应用系统中,存储系统的操作通常是由协处理器CP15完成的.CP15包含16个32位的寄存器,其编号为0-15. 而访问CP15寄存器的指令主要是MCR和MRC这两个指令. 例 ...

  10. Android 日夜间切换Demo

    这是其中一种实现模式,也是比较麻烦的一种,首先写布局,不多说上代码 activity_main.xml <?xml version="1.0" encoding=" ...