Codefroces432 div2 A,B,C

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>=0 && 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 0;
}

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[4];
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=0;
    if(dist(node[1],node[0])==dist(node[1],node[2])) ans=1;
    if(ans) return true;
    else return false;
}
bool solve()
{
    double a=((node[1].y-node[0].y)*1.0)/((node[1].x-node[0].x)*1.0);
    double b=((node[2].y-node[0].y)*1.0)/((node[2].x-node[0].x)*1.0);
    if(a==b) return true;
    return false;
}
int main()
{
    for(int i=0;i<3;i++)
    {
        scanf("%lld%lld",&node[i].x,&node[i].y);
    }
    if(solve()) puts("No");
    else if(check()) puts("Yes");
    else puts("No");
    return 0;
}

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

60 0 0 0 01 0 0 0 00 1 0 0 00 0 1 0 00 0 0 1 00 0 0 0 1

Output

11

Input

30 0 1 2 00 0 9 2 00 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;
struct Point{
    ll a, b, c, d, e;
}nod[1006];
bool vis[1006];
ll check(Point aa, Point bb, Point cc) {
    return (bb.a-aa.a)*(cc.a-aa.a)+(bb.b-aa.b)*(cc.b-aa.b)+(bb.c-aa.c)*(cc.c-aa.c)+(bb.d-aa.d)*(cc.d-aa.d)+(bb.e-aa.e)*(cc.e-aa.e);
}
int main(){
    int n;
    memset(vis, true, sizeof(vis));
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> nod[i].a >> nod[i].b >> nod[i].c >> nod[i].d >> nod[i].e;
    }
    int k = n;
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j <= n; j ++) {
            for(int l = j+1; l <= n; l ++) {
                if(i != j && i != l) {
                    if(check(nod[i], nod[j], nod[l]) > 0) {
                        vis[i] = false;
                        k--;
                        goto tt;
                    }
                }
            }
        }
        tt:;
    }
    printf("%d\n",k);
    int cnt = 0;
    for(ll i = 1; i <= n; i ++) {
        if(vis[i]) {
            cnt ++;
            printf("%lld ",i);
        }
    }
    if(k!=0)printf("\n");
    return 0;
}
时间: 2024-10-14 00:59:12

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

cf386(div2)大一狗ACM之路

#cf386(div2)总结#前两题很顺利的做了出来, c题扔了, D题wrong了5发才A掉.A题签到题, 但是想多了, 代码写的有点长了. 找被整除最小值*7.B题 读题读了一会, 读完了就有思路了, 1A. 字符串问题, 从后往前两个两个的放到新的字符串里, 一个从最左, 一个从最右, 模拟指针扫着放, 最后特判会不会扫到一起.C题跳了没看, 最后做完了D题回来看了一眼没什么思路 日后再说.D题, 恩.. 两个多小时都用在这题上面了, 20分钟的时候做完了B之后就一直再啃D题, 暴力判断啊

Codeforces gym Hello 2015 Div1 B and Div2 D

Codeforces gym 100571 problem D Problem 给一个有向图G<V,E>和源点S,边的属性有长度L和颜色C,即E=<L,C>.进行Q次询问,每次给定一个点X,输出S到X的最短路的长度(不存在则输出 -1).但要求S到X的路径中相邻两条边颜色不一样. Limits Time Limit(ms): 1000 Memory Limit(MB): 256 |V|, |E|: [1, 10^5] X, S: [1, |V| ] L: [1, 10^9] |C|

编写css让div2在div1的右下角?

<style>#div1{ width:200px; height:200px; background-color:#F00;}#div2{ width:50px; height:50px; background:#FF0; position:relative; left:75%; top:75%; }</style></head> <body><div id="div1"> <div id="div2&quo

codeforces round #257 div2 C、D

本来应该认真做这场的,思路都是正确的. C题,是先该横切完或竖切完,无法满足刀数要求,再考虑横切+竖切(竖切+横切), 因为横切+竖切(或竖切+横切)会对切割的东西产生交叉份数,从而最小的部分不会尽可能的大. 代码如下,虽然比较长.比较乱,但完全可以压缩到几行,因为几乎是4小块重复的代码,自己也懒得压缩 注意一点,比如要判断最小块的时候,比如9行要分成2份,最小的剩下那份不是9取模2,而应该是4 m/(k+1)<=m-m/(k+1)*k          #include<bits/stdc+

codeforces Round #250 (div2)

a题,就不说了吧 b题,直接从大到小排序1-limit的所有数的lowbit,再从大到小贪心组成sum就行了 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #define N 200000 6 using namespace std; 7 int pos[N],a[N],s[N],f[N],la[N],b[N],i,j,k,ans,n,p

SRM621 (div2)

TwoWaysSorting sort.... NumbersChallenge 01dp... MixingColors loading..... SRM621 (div2),布布扣,bubuko.com

Codeforces 583 DIV2 Robot&#39;s Task 贪心

原题链接:http://codeforces.com/problemset/problem/583/B 题意: 就..要打开一个电脑,必须至少先打开其他若干电脑,每次转向有个花费,让你设计一个序列,使得总花费最小. 题解: 就傻傻的走就好..从左走到右,再走回来,更新序列和答案就好. 代码: #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #define MA

Codeforces #180 div2 C Parity Game

// Codeforces #180 div2 C Parity Game // // 这道题的题目意思就不解释了 // // 题目有那么一点难(对于我而言),不多说啦 // // 解题思路: // // 首先如果a串和b串相等,不多说直接YES // 如果b串全是0,直接YES // 注意到a串有一个性质,1的个数不会超过本身的加1. // a有个1的上限设为x,b有个1的个数设为y,则如果x < y // 那么直接NO. // // 现在一般情况下,就是模拟啦,找到a的后缀和b的前缀一样的

codeforce 285 div2 D 题解

codeforce 285 div2 D 题解 说明 这道题目是看了思路分析才知道的,关键问题在于数据量过大,需要快速检索的同时不能辅助空间过大. 因此利用了下面3种方法结合解决该问题 康拓展开与逆康拓展开 树状数组 二分查找 代码 /** * @brief Codeforces Round #285 (Div. 2) d * @file d.cpp * @author mianma * @created 2015/01/27 18:18 * @edited 2015/01/29 22:45 *