Thứ Tư, 27 tháng 4, 2022

BONES C++

#include <bits/stdc++.h>
using namespace std;
int s1,s2,s3,d[100],s,maxx=0,p;
void xuli()
{
    cin>>s1>>s2>>s3;
    for (int i=1;i<=s1;i++)
    {
        for (int j=1;j<=s2;j++)
        {
            for (int k=1;k<=s3;k++)
            {
                s=i+j+k;
                d[s]++;
            }
        }
    }
    maxx=0;
    for (int i=1;i<=s1+s2+s3;i++)
    {
       //cout<<d[i]<<endl;
        if (maxx<d[i])
        {
            maxx=d[i];
            p=i;
        }
    }
    cout<<p;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    freopen("bones.inp","r",stdin);
    freopen("bones.out","w",stdout);
    xuli();
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.