A. Arpa and a research in Mexican wave

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 n, k, t (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 <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,m,k;
int main()
{
scanf("%d%d%d",&n,&m,&k);
if(k>= && k<=m) printf("%d\n",k);
else if(k>m && k<=n) printf("%d\n",m);
else if(k>n && k<=n+m) printf("%d\n",m-k+n);
else printf("0\n");
return ;
}
B. Arpa and an exam about geometry

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

 三点共线一定不存在,除此之外,若a到b的距离等于b到c的距离存在。

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
struct point
{
ll x;
ll y;
}node[];
ll dist(point a,point b)
{
return ((a.y-b.y)*(a.y-b.y))+((a.x-b.x)*(a.x-b.x));
}
bool check()
{
int ans=;
if(dist(node[],node[])==dist(node[],node[])) ans=;
if(ans) return true;
else return false;
}
bool solve()
{
double a=((node[].y-node[].y)*1.0)/((node[].x-node[].x)*1.0);
double b=((node[].y-node[].y)*1.0)/((node[].x-node[].x)*1.0);
if(a==b) return true;
return false;
}
int main()
{
for(int i=;i<;i++)
{
scanf("%lld%lld",&node[i].x,&node[i].y);
}
if(solve()) puts("No");
else if(check()) puts("Yes");
else puts("No");
return ;
}
C. Five Dimensional Points

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.

暴力枚举


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll a[][];
int n,vis[];
set<ll>s;
bool check(int x,int y,int z)
{
ll pos=;
for(int i=;i<;i++)
pos+=(a[y][i]-a[x][i])*(a[z][i]-a[x][i]);
if(pos>) return false;
return true;
}
int main()
{
scanf("%d",&n);
for(int i=;i<n;i++)
{
s.insert(i+);
for(int j=;j<;j++)
scanf("%lld",&a[i][j]);
}
int l=n;
for(int i=;i<n;i++)
{
for(int j=;j<n;j++)
{
for(int k=j+;k<n;k++)
{
if(i!=j && i!=k)
{
if(!check(i,j,k))
{
l--;
s.erase(i+);
goto eg;
}
}
}
}
eg:;
}
printf("%d\n",l);
if(s.size())
{
for(set<ll>::iterator it=s.begin();it!=s.end();it++)
{
printf("%lld\n",*it);
}
}
return ;
}


Codefroces432 div2 A,B,C的更多相关文章

  1. bc#54 div2

    用小号做的div2 A:竟然看错了排序顺序...白白WA了两发 注意读入一整行(包括空格):getline(cin,st) [gets也是资瓷的 #include<iostream> us ...

  2. $('div a') 与$('div>a'),.div+.div2与.div~.div2

    $('div a'):div标签下所有层次a元素的jquery对象 $('div>a'):div标签下子元素层次a元素的jquery对象 <body> <div class=' ...

  3. SRM 657 DIV2

    -------一直想打SRM,但是感觉Topcoder用起来太麻烦了.题目还是英文,不过没什么事干还是来打一打好了.但是刚注册的号只能打DIV2,反正我这么弱也只适合DIV2了.. T1: 题目大意: ...

  4. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  5. Codeforce Round #211 Div2

    真的是b到不行啊! 尼玛C题一个这么简单的题目没出 aabbccddee 正确的是aabccdee 我的是   aabcdee 硬是TM的不够用,想半天还以为自己的是对的... A:题... B:题. ...

  6. Topcoder srm 632 div2

    脑洞太大,简单东西就是想复杂,活该一直DIV2; A:水,基本判断A[I]<=A[I-1],ANS++; B:不知道别人怎么做的,我的是100*N*N;没办法想的太多了,忘记是连续的数列 我们枚 ...

  7. TopCoder 603 div1 & div2

    div2 250pts MiddleCode 题意:s串长度为奇数时,将中间字符取掉并添加到t末尾:长度为偶数时,将中间两个较小的字符取掉并添加到末尾. 分析:直接做,学习了一下substr(s, p ...

  8. TopCoder 649 div1 & div2

    最近一场TC,做得是在是烂,不过最后challenge阶段用一个随机数据cha了一个明显错误的代码,最后免于暴跌rating,还涨了一点.TC题目质量还是很高的,非常锻炼思维,拓展做题的视野,老老实实 ...

  9. 220 DIV2 B. Inna and Nine

    220 DIV2 B. Inna and Nine input 369727 output 2 input 123456789987654321 output 1 题意:比如例子1:369727--& ...

随机推荐

  1. 搭建app自动化测试环境(一)

    ①:想实现自动化,第一步先安装python然后第二步安装selenium, 第三步安装JDK,然后J配置好JDK环境变量 JAVA_HOME    C:\Program Files\Java\jdk1 ...

  2. PID三种参数的理解

    来源:http://blog.gkong.com/liaochangchu_117560.ashx PID是比例.积分.微分的简称,PID控制的难点不是编程,而是控制器的参数整定.参数整定的关键是正确 ...

  3. 洛谷—— P1855 榨取kkksc03

    https://www.luogu.org/problem/show?pid=1855 题目描述 洛谷2的团队功能是其他任何oj和工具难以达到的.借助洛谷强大的服务器资源,任何学校都可以在洛谷上零成本 ...

  4. [Transducer] Create a Sequence Helper to Transduce Without Changing Collection Types

    A frequent use case when transducing is to apply a transformation to items without changing the type ...

  5. 程序设计基石与实践系列之编写高效的C程序与C代码优化

    原文出处: codeproject:Writing Efficient C and C Code Optimization 虽然对于优化C代码有非常多有效的指导方针,可是对于彻底地了解编译器和你工作的 ...

  6. js php 数组比較

    php 与 javascript 数组除了定义以及 操作上有非常大的差别,还有非常多其他的差别.如今我们就来讨论讨论.    1.大家都知道php比較两个数组是否全相等(值,索引)相等 $a=arra ...

  7. 在KVM中执行windows 10虚机(by quqi99)

    作者:张华  发表于:2015-12-22版权声明:能够随意转载.转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 ( http://blog.csdn.net/quqi99 ) KVM ...

  8. WET Dilutes Performance Bottlenecks

    WET Dilutes Performance Bottlenecks Kirk Pepperdine THE IMPORTANCE OF THE DRY PRINCIPLE (Don't Repea ...

  9. The broken pedometer-纯暴力枚举

    The broken pedometer Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu i ...

  10. 51Nod 1433 0和5(数论)

    小K手中有n张牌,每张牌上有一个一位数的数,这个字数不是0就是5.小K从这些牌在抽出任意张(不能抽0张),排成一行这样就组成了一个数.使得这个数尽可能大,而且可以被90整除. 注意: 1.这个数没有前 ...