Easy Task

Time Limit: 2 Seconds Memory Limit: 65536 KB

题目:
You are given n integers. Your task is very easy. You should find the maximum integer a and the minimum integer b among these nintegers. And then you should replace both a and b with a-b. Your task will not be finished unless all the integers are equal.Now the problem come, you want to know whether you can finish you task. And if you can finish the task, you want to know the final result.
Input
The first line of the input contain an integer T(T≤ 20) indicates the number of test cases.Then T cases come. Each case consists of two lines. The first line is an integer n(2≤ n≤ 10) as the problem described. The second line contains n integers, all of them are no less than -100000 and no more than 100000.
Output
For each case you should print one line. If you can finish your task, you should print one of the n integers. Otherwise, you should print “Nooooooo!”(without quotes)

Sample Input
2
3
1 2 3
2
5 5
Sample Output2
5

难度:签到题
说一下我的思路吧:
超简单的一道题,,,但是做题的时候虽然有算过一些数值组合,一直没有输出Nooooooo,然后我就想能不能有一些特殊值没有想到,然后就没有上交,,,然后我就想的有点多了,这道题,只需要将输入的数字排序,然后用最后一个数值-第一个数值,再把两个数值替换为这个差值,比较者这些数字是否相等,若相等,则输出这些数字中的相同的数字。(不存在输出Nooooooo的情况)。一下就是我的代码。

代码:

#include <bits/stdc++.h> 
using namespace std;
int n;
int a[15];

bool equall()
{
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i-1])
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int t;
    cin>>t;
    int max_,min_,m;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        max_=a[n-1];
        min_=a[0];
        while(equall())
        {
            sort(a,a+n);
            max_=a[n-1];
            min_=a[0];
            m=max_-min_;

            a[n-1]=m;
            a[0]=m;
        }
        cout<<a[0]<<endl;

    }
    return 0;
}

您可以通过以下几个步骤来下载EasyDarwin: 1. 首先,访问EasyDarwin的GitHub仓库页面,链接为https://github.com/EasyDarwin/EasyDarwin。 2. 在该页面上,找到并点击"Release"选项卡,然后选择合适的版本进行下载。 3. 下载完成后,解压缩文件到您的计算机上。 请注意,根据引用中的说明,下载的文件应该包含一个名为"start.bat"的文件。在Windows环境下,运行该文件即可启动EasyDarwin,并在浏览器中输入http://localhost:10008访问登录界面。 希望这个回答能够帮助到您!123 #### 引用[.reference_title] - *1* [EasyDarwin-开源的rtmp流媒体服务器](https://blog.csdn.net/yyo201/article/details/81874214)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *2* [从零开始搭建EasyDarwin环境——git的安装下载及拉取EasyDarwin代码运行](https://blog.csdn.net/TsingSee/article/details/121774244)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *3* [EasyDarwin 笔记](https://blog.csdn.net/weixin_39746229/article/details/111536570)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值