CodeForces 617D Polyline

无脑暴力判断。

#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<list>
#include<algorithm>
using namespace std;

struct point
{
    long long x;
    long long y;
}p1,p2,p3;

int main()
{
    scanf("%lld%lld",&p1.x,&p1.y);
    scanf("%lld%lld",&p2.x,&p2.y);
    scanf("%lld%lld",&p3.x,&p3.y);

    if(p1.x==p2.x&&p2.x==p3.x) printf("1\n");
    else if(p1.y==p2.y&&p2.y==p3.y) printf("1\n");
    else if(p1.y==p2.y&&(p3.x>=max(p1.x,p2.x)||p3.x<=min(p1.x,p2.x))) printf("2\n");
    else if(p3.y==p2.y&&(p1.x>=max(p3.x,p2.x)||p1.x<=min(p3.x,p2.x))) printf("2\n");
    else if(p1.y==p3.y&&(p2.x>=max(p1.x,p3.x)||p2.x<=min(p1.x,p3.x))) printf("2\n");
    else if(p1.x==p2.x&&(p3.y>=max(p1.y,p2.y)||p3.y<=min(p1.y,p2.y))) printf("2\n");
    else if(p3.x==p2.x&&(p1.y>=max(p3.y,p2.y)||p1.y<=min(p3.y,p2.y))) printf("2\n");
    else if(p1.x==p3.x&&(p2.y>=max(p1.y,p3.y)||p2.y<=min(p1.y,p3.y))) printf("2\n");
    else printf("3\n");
    return 0;
}
时间: 2024-12-25 02:19:00

CodeForces 617D Polyline的相关文章

codeforces Round #320 (Div. 2) C. A Problem about Polyline(数学)

解题思路: 我们可以发现这样的一个规律: (1)首先b一定要小于a,否则无论如何曲线也无法通过(a,b); (2)设int k=a/b, 如果k为奇数,说明这个点在上图的绿色的线上, 没关系,我们让 k+=1:这样的话一定有(0,0), (a,b)这两点确定的直线的 斜率1/k介于(1/(k-1),  1/(k+1))之间,那么我们可以通过缩小(或者放大)X的值,使得第 k/2 个周期块 斜率为-1的那条边经过(a, b).此时 的X值就是最小的! (3)如果(a,b)在第 k/2 个周期块 斜

Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] A A Problem about Polyline

题目中给出的函数具有周期性,总可以移动到第一个周期内,当然,a<b则无解. 假设移动后在上升的那段,则有a-2*x*n=b,注意限制条件x≥b,n是整数,则n≤(a-b)/(2*b).满足条件的x≥(a-b)/(2*n) 假设在下降的那段,2*x-(a-2*x*n)=b,n+1≤(a+b)/(2*b),x≥(a+b)/(2*(n+1)) 两者取最小值 #include<bits/stdc++.h> using namespace std; int main() { int a,b; sc

Analyzing Polyline -- Codeforces Round #123 (Div. 2)

题意:https://codeforc.es/problemset/problem/195/D 求折线段数. 思路: 对pos进行sort,对不同区间段加k,两个dp处理不同k>0 or k<0前后缀,判断即可. 注意:long double,ESP=1e-20. 1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #includ

Codeforces Round#320 Div2 解题报告

Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Finding Team Member codeforces 579C A Problem about Polyline codeforces 579D "Or" Game codeforces 579E Weakness and Poorness codeforces 579F LCS Aga

Codeforces Round #249 (Div. 2) (ABCD题解)

比赛链接:http://codeforces.com/contest/435 A. Queue on Bus Stop time limit per test:1 second memory limit per test:256 megabytes It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of p

[Codeforces] Round #320 (Div.2)

1.前言 虽然这次我依旧没有参加正式比赛,但是事后还是看了看题目的...一般不怎么刷Codeforces. A.Raising Bacteria You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night

【codeforces 718E】E. Matvey&#39;s Birthday

题目大意&链接: http://codeforces.com/problemset/problem/718/E 给一个长为n(n<=100 000)的只包含‘a’~‘h’8个字符的字符串s.两个位置i,j(i!=j)存在一条边,当且仅当|i-j|==1或s[i]==s[j].求这个无向图的直径,以及直径数量. 题解:  命题1:任意位置之间距离不会大于15. 证明:对于任意两个位置i,j之间,其所经过每种字符不会超过2个(因为相同字符会连边),所以i,j经过节点至多为16,也就意味着边数至多

Codeforces 124A - The number of positions

题目链接:http://codeforces.com/problemset/problem/124/A Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing b

Codeforces 841D Leha and another game about graph - 差分

Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or  - 1. To pass th