首页 > 其他 > 详细

CodeForces 719A. Vitya in the Countryside

时间:2018-07-25 13:32:31      阅读:129      评论:0      收藏:0      [点我收藏+]

题意:

给你一个数列(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1),然后重复循环这个数列,输入一个n,再输入有n个元素的某段,问你接下来是UP还是DOWN,若无法判断输出-1。
思路:
枚举各种情况,注意n==1,a[n]==15是DOWN。

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,a[100];
    cin>>n;

        for(i=1;i<=n;i++)
        cin>>a[i];
        
        if(n==1&&a[n]==0){
            cout<<"UP\n";
        }
        else if(n==1&&a[n]==15){
            cout<<"DOWN\n";
        }
        else if(n==1&&a[n]!=0)
        {
            cout<<-1<<endl;
        }
        else if(a[n-1]<a[n]&&a[n]!=15)
        {
            cout<<"UP\n";
        }
        else if(a[n-1]<a[n]&&a[n]==15){
            cout<<"DOWN\n";
        }
        else if(a[n-1]>a[n]&&a[n]!=0){
            cout<<"DOWN\n";
        }
        else if(a[n-1]>a[n]&&a[n]==0){
            cout<<"UP\n";
        }
    return 0;
}

CodeForces 719A. Vitya in the Countryside

原文:https://www.cnblogs.com/mch5201314/p/9365338.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!