SDUT 2018 暑期大一集训组队赛之小小鲤鱼加油站2(数据结构+程序设计基础组)

https://vjudge.net/contest/247919#problem/I
A.

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int n, sum;
    cin >> n;
    sum = 0;
    sum = n * (1 + n) / 2  - n + 1;
    cout<<sum<<endl;
    return 0;
}

B.

#include <bits/stdc++.h>
using namespace std;

int mi(int a, int b)
{
    return a * a + b * b;
}
int main()
{
    int a, b, c, d, x, y;
    cin >> a >> b >> c >> d;
    x = mi(a,b);
    y = mi(c,d);
    if(x > y) printf("Wil\n");
    else if( x < y) printf("Russo\n");
    else printf("Empate\n");
    return 0;
}

C.

#include <bits/stdc++.h>
using namespace std;
struct node
{
    int x, y, z;
}t[5001];
int main()
{
    int n, x, y, z, i, j;
    char s[5];
    scanf("%d",&n);
     i = 0;
    while(n--)
    {

        scanf("%s",s);
        scanf("%d %d %d", &x, &y, &z);
        if(s[0] == 'A')
        {
            if(!i)
            {
                t[i].x = x;
                t[i].y = y;
                t[i++].z = z;
                printf("Ok\n");
            }
            else
            {
                for(j = 0; j < i; j++)
                {
                    if((t[j].x - x) * (t[j].x - x) +(t[j].y - y) * (t[j].y - y) < (t[j].z + z) * (t[j].z +z) )
                      {
                           printf("No\n");
                           break;
                      }
                }
            if(j >= i)
            {
                 t[i].x = x;
                t[i].y = y;
                t[i++].z = z;
                printf("Ok\n");
            }
        }
    }
    else
    {
        int f = 1;
        for(j = 0; j < i; j++)
        {
            if(t[j].x == x && t[j].y == y && t[j].z == z)
            {
                int l = j;
                for(; l < i - 1; l++)
                {
                    t[l] = t[l+1];
                }
                i--;
                f = 0;
                printf("Ok\n");
                break;
            }
        }
        if(f) printf("No\n");
        }
    }
    return 0;
}

D.

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int n, s, sum, a[100010];
    cin>>n;
    s = 0;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        s += a[i];
    }
    sum = 0;
    for(int
    i = 0; i < n; i++)
    {
        s -= a[i];
        sum += a[i] * s;
    }
    cout<<sum<<endl;
    return 0;
}

F.

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, s, x;
    cin>>n;
    s = 0;
    for(int i; i < n; i++)
    {
        cin >> x;
        s += x;
    }
    int y = s/5;
    if(s % 5)
        y++;
    cout << y << endl;
    return 0;
}

G.

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int n, i, k, m;
   long long a[5] = {0};
   scanf("%d",&n);
   for(i=1; i <= n; i++)
   {
       k = i;
       while(k > 4)
       {
           k -= 4;
       }
       scanf("%d",&m);
       a[k] += m;
   }
   int max = a[1];
   int j = 1;
   for(i = 2; i <= 4; i++)
   {
       if(max < a[i])
       {
           max = a[i];
           j = i;
       }
   }
   for(i = 1; i <= 4; i++)
   {
       if(max == a[i] && i != j)
       {
           if(i < j)
           {
               j = i;
           }
       }
   }
   printf("%c\n",64 +j);
    return 0;
}

L.

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int n, a, s, x;
   cin>>n;
   x = 10000;
   s = 0;
   for(int i = 0; i < n; i++)
   {
       cin>>a;
       s += a;
       if(a % 2)
       {
           if(a < x)
            x = a;
       }
   }
   if(s % 2)
    s -= x;
   cout<<s<<endl;
    return 0;
}

I.

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long t, a, b;
    cin>>t;
    while(t--)
    {
        cin>>a>>b;
        if((a - b >= 0 && a - b <= 1)||(b - a >= 0 && b - a <= 1))
            cout << "OK" << endl;
        else
        {
            if( (a + b) & 2)
            {
                cout << (a + b) / 2 << " " << (a + b) / 2 + 1 <<endl;
            }
            else
                cout << (a + b) / 2 << " " << (a + b) / 2 << endl;
        }
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值