A. Vitya in the Countryside
1 second
256 megabytes
standard input
standard output
Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down.
Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units) for each day is 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, and then cycle repeats, thus after the second 1 again goes 0.
As there is no internet in the countryside, Vitya has been watching the moon for n consecutive days and for each of these days he wrote down the size of the visible part of the moon. Help him find out whether the moon will be up or down next day, or this cannot be determined by the data he has.
The first line of the input contains a single integer n (1 ≤ n ≤ 92) — the number of consecutive days Vitya was watching the size of the visible part of the moon.
The second line contains n integers ai (0 ≤ ai ≤ 15) — Vitya's records.
It's guaranteed that the input data is consistent.
If Vitya can be sure that the size of visible part of the moon on day n + 1 will be less than the size of the visible part on day n, then print "DOWN" at the only line of the output. If he might be sure that the size of the visible part will increase, then print "UP". If it's impossible to determine what exactly will happen with the moon, print -1.
5
3 4 5 6 7
UP
7
12 13 14 15 14 13 12
DOWN
1
8
-1
In the first sample, the size of the moon on the next day will be equal to 8, thus the answer is "UP".
In the second sample, the size of the moon on the next day will be 11, thus the answer is "DOWN".
In the third sample, there is no way to determine whether the size of the moon on the next day will be 7 or 9, thus the answer is -1.
一开始没注意只有0或15的情况,被hack了,QAQ
#include<iostream>
using namespace std; int S[]={, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , };
int n,m;
int A[]; int main()
{
cin>>n;
for(int i=;i<=n;i++)
cin>>A[i];
if(n==)
switch(A[])
{
case :
cout<<"UP";
return ;
case :
cout<<"DOWN";
return ;
default:
cout<<-;
return ;
}
for(int i=;i<=;i++)
if(A[n-]==S[i-]&&A[n]==S[i])
m=i;
if((<=m&&m<=)||(m==))
{
cout<<"UP";
return ;
}
else
if(<=m&&m<=)
{
cout<<"DOWN";
return ;
}
cout<<-;
return ;
}
A. Vitya in the Countryside的更多相关文章
- 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:Vitya in the Countryside
Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he go ...
- Vitya in the Countryside
Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge war ...
- 【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 ...
- 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
链接:[http://codeforces.com/group/1EzrFFyOc0/contest/719/problem/A] 题意: 给你一个数列(0, 1, 2, 3, 4, 5, 6, 7, ...
- CodeForces 719A Vitya in the Countryside (水题)
题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, & ...
随机推荐
- Ubuntu设置打不开排错
记录一次系统设置打不开排错过程 系统信息: ××××××:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu ...
- thinkphp5实现mysql数据库备份
其实备份数据库说白了就是向一个.sql的文档中写入一条一条的sql命令 public function back() { $to_file_name="backsql.sql"; ...
- nutzboot 使用nacos替换zookeeper
先放一段从网上拷贝一段分布式CAP理论的概念 分布式领域中存在CAP理论,且该理论已被证明:任何分布式系统只可同时满足两点,无法三者兼顾. ①C:Consistency,一致性,数据一致更新,所有数据 ...
- mysql5.7安装部署后初始密码查看以及修改
一.查看初始密码以下两种方法: 1.找到自己的error.log日志文件,执行自己的命令,红色标记的部分为初始化密码. grep 'temporary password' /data/mysql/er ...
- c#字符串字面量
分为两种: 1 常规字符串字面量 2逐字字面量字符串:以@字符为前缀.注意:注意逐字字面量唯一例外的是相邻的双引号组,它们被解释为单个双引号字符.
- dynomite:高可用多数据中心同步
https://github.com/Netflix/dynomite Dynomite, inspired by Dynamo whitepaper, is a thin, distributed ...
- c#基础值类和引用类型_字符串
值类型和引用类型区别:1.值类型和引用类型在内存上存储的地方不一样.2.在传递值类型和传递引用类型的时候,传递的方式不一样.值类型我们称之为值传递,引用类型我们称之为引用传递.我们学的值类型和引用类型 ...
- Java虚拟机内存分配与回收策略
内存分配与回收策略 Minor GC 和 Full GC Minor GC:发生在新生代上,因为新生代对象存活时间很短,因此 Minor GC 会频繁执行, 执行的速度一般也会比较快. Full GC ...
- Redis set(集合)
Redis 的 Set 是 String 类型的无序集合,元素不允许重复. Redis 中集合是通过哈希表实现的,所以添加,删除,查找的复杂度都是 O(1). 集合中最大的元素数为 232 - 1 ( ...
- springboot集成shiro实现验证码校验
github:https://github.com/peterowang/shiro/ 这里实现验证码校验的思路是自己添加一个Filter继承FormAuthenticationFilter,Form ...