CodeForces 719A. Vitya in the Countryside
链接:[http://codeforces.com/group/1EzrFFyOc0/contest/719/problem/A]
题意:
给你一个数列(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。
思路:
枚举各种情况,注意n1,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的更多相关文章
- codeforces 719A Vitya in the Countryside(序列判断趋势)
题目链接:http://codeforces.com/problemset/problem/719/A 题目大意: 题目给出了一个序列趋势 0 .1 .2 .3 ---14 .15 .14 ----3 ...
- CodeForces 719A Vitya in the Countryside 思维题
题目大意:月亮从0到15,15下面是0.循环往复.给出n个数字,如果下一个数字大于第n个数字输出UP,小于输出DOWN,无法确定输出-1. 题目思路:给出0则一定是UP,给出15一定是DOWN,给出其 ...
- CodeForces 719A Vitya in the Countryside (水题)
题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, & ...
- Code forces 719A Vitya in the Countryside
A. Vitya in the Countryside time limit per test:1 second memory limit per test:256 megabytes input:s ...
- Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 水题
A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...
- Codeforces 719A 月亮
参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6395221.html A. Vitya in the Countryside time limit ...
- A. Vitya in the Countryside
A. Vitya in the Countryside time limit per test 1 second memory limit per test 256 megabytes input s ...
- codeforces 719A:Vitya in the Countryside
Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he go ...
- 【32.89%】【codeforces 719A】Vitya in the Countryside
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
随机推荐
- lua table排序报错与解决
lua table排序 table的sort函数 比如按照大小进行排序,下面这种写法在某些情况下可能会排序错误,甚至报invalid order function for sorting table. ...
- 利用python搭建Powersploit powershell脚本站点
powershell脚本站点的搭建 一.Powersploit Powersploit是一款基于powershell的后渗透(Post-Exploitation)框架,集成大量渗透相关模块和功能. 下 ...
- Linux 中数组的使用
Linux中数组本人可能用的相对较少,但是会经常遇见,也容易忘记,就顺便记录下来吧 数值类型的数组:一对括号表示数组,数组中元素之间使用“空格”来隔开 arr=(1 2 3 4 5) 字符串类型数组: ...
- 计数排序与桶排序python实现
计数排序与桶排序python实现 计数排序 计数排序原理: 找到给定序列的最小值与最大值 创建一个长度为最大值-最小值+1的数组,初始化都为0 然后遍历原序列,并为数组中索引为当前值-最小值的值+1 ...
- 通过一篇YAML来学习YAML
yaml 兼容 json,至今已发展至 1.2版.支持N多种编程语言.官网:http://www.yaml.org/ 格式在线校验:http://nodeca.github.io/js-yaml/ 下 ...
- PHP中的Session工作原理
一直在使用session存储数据,一直没有好好总结一下session的使用方式以及其工作原理,今天在这里做一下梳理. 这里的介绍主要是基于php语言,其他的语言操作可能会有差别,但基本的原理不变. 1 ...
- 怎样用命令行开启或关闭Windows服务
怎样用命令行开启或关闭Windows服务 本篇博客主要包含一个内容: 怎样用命令行开启或关闭Windows服务 闲话少叙,直奔主题. 1.在桌面右击新建一个文本文档,然后打开. 2.找到需要开启或关闭 ...
- eclipse使用CXF3.1.*创建webservice服务端客户端以及客户端手机APP(二)
eclipse使用CXF3.1.*创建webservice服务端客户端以及客户端手机APP(二) 接上篇博客,本篇博客主要包含两个内容: 4.使用Android studio创建webservice客 ...
- 安装完最小化 RHEL/CentOS 7 后需要做的 30 件事情(一)转载自码农网
CentOS 是一个工业标准的 Linux 发行版,是红帽企业版 Linux 的衍生版本.你安装完后马上就可以使用,但是为了更好地使用你的系统,你需要进行一些升级.安装新的软件包.配置特定服务和应用程 ...
- ES5-ES6-ES7_iterator和for of
iterator(遍历器)的概念 JavaScript原有的表示“集合”的数据结构,主要是数组(Array)和对象(Object),ES6又添加了Map和Set.这样就有了四种数据集合,用户还可以组合 ...