CF 第18场 简单题目一览表

来源:互联网 发布:剑三五毒成女捏脸数据 编辑:程序博客网 时间:2024/06/09 23:28
A:A:#include<iostream>#include<cstdio>#define sqr(x) ((x)*(x))using namespace std;int wx[4] = { -1 , 0 , 1 , 0 };int wy[4] = { 0 , -1 , 0 , 1 };struct point {    int x , y;};point P[3];int dist2( point A , point B ) {    return sqr( A.x - B.x ) + sqr( A.y - B.y );}bool check() {    int a = dist2( P[0] , P[1] );    int b = dist2( P[0] , P[2] );    int c = dist2( P[1] , P[2] );    if ( a == 0 || b == 0 || c == 0 ) return false;    if ( a > c ) swap( a , c );    if ( b > c ) swap( b , c );    return ( a + b - c == 0 );}int main() {    cin >> P[0].x >> P[0].y >> P[1].x >> P[1].y >> P[2].x >> P[2].y;    if ( check() ) {        printf( "RIGHT\n" );        return 0;    }    for ( int i = 0 ; i < 3 ; i++ )        for ( int j = 0 ; j < 4 ; j++ ) {            P[i].x += wx[j];            P[i].y += wy[j];            if ( check() ) {                printf( "ALMOST\n" );                return 0;            }            P[i].x -= wx[j];            P[i].y -= wy[j];        }    printf( "NEITHER\n" );    return 0;}B:#include<iostream>#include<cstdio>using namespace std;int n,d,m,l;int main(){   //freopen("//media/学习/ACM/input.txt","r",stdin);    while(~scanf("%d%d%d%d",&n,&d,&m,&l))    {        long long  a,b,idx=0,k=1;        while(k<=n)        {             a=k*l+(k-1)*(m-l);             b=k*m-1;            if(a/d!=b/d)break;            k++;        }        printf("%lld\n",(a/d)*d+d);    }    return 0;}C

C

#include <iostream>#include <vector>#include <string>#include <math.h>#include <ctype.h>#include <stack>#include <queue>#include <map>#include <set>using namespace std;int main(){int n;cin >> n;vector <int> arr(n);int s1=0,s2=0;int a = 0;for (int i = 0; i < n; i ++){cin >> arr[i];s2 += arr[i];}for (int i = 0; i < n-1; i ++){s1 += arr[i];s2 -= arr[i];if (s1 == s2)a ++;}cout << a;return 0;}


原创粉丝点击