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. unity 调用 .dll 或 .so时遇到的问题

    1.32位的 .dll 无法在64位的unity编辑器下运行. System.DllNotFoundException: xxx  , 64位的程序运行32位的dll是会报这种错 2.Failed t ...

  2. 2019年北航OO第二单元(多线程电梯任务)总结

    一.三次作业总结 1. 说在前面 对于这次的这三次电梯作业,我采用了和几乎所有人都不同的架构:将每个人当作一个线程.这样做有一定的好处:它使得整个问题的建模更加自然,并且在后期人员调度变得复杂时,可以 ...

  3. Java基础学习总结(7)——Object类

    一.Object类介绍 Object类在JAVA里面是一个比较特殊的类,JAVA只支持单继承,子类只能从一个父类来继承,如果父类又是从另外一个父类继承过来,那他也只能有一个父类,父类再有父类,那也只能 ...

  4. 如何检查 Android 应用的内存使用情况

    Android是为移动设备而设计的,所以应该关注应用的内存使用情况.尽管Android的Dalvik虚拟机会定期执行垃圾回收操作,但这也不意味着就可以忽视应用在何时何处进行内存分配和释放.为了提供良好 ...

  5. iOS AES的加密解密

    主要是要得到加密后的原来的字符创,MD5无法得到原有的,仅仅能用AES+base64 要用GTMBase64这个能够自己去下载, 主要看另外2个类文件. #import <Foundation/ ...

  6. iOS CST NSDate

    好像是从ios4.1開始[NSDate date];获取的是GMT时间,这个时间和北京时间相差8个小时.下面代码能够解决问题 - (void)tDate { NSDate *date = [NSDat ...

  7. node03--http

    form.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  8. 如何解读「量子计算应对大数据挑战:中国科大首次实现量子机器学习算法」?——是KNN算法吗?

    作者:知乎用户链接:https://www.zhihu.com/question/29187952/answer/48519630 我居然今天才看到这个问题,天……本专业,有幸听过他们这个实验的组会来 ...

  9. java连接操作Oracle

    package com.sp.test; import java.sql.*; import java.util.*; public class Text_lianxi extends Thread ...

  10. Android项目实战(五十五):部分机型点击home再点图标进入程序不保留再之前界面的问题

    解决办法: 1.在基类Activity中 添加方法 @Override public boolean moveTaskToBack(boolean nonRoot) { return super.mo ...