Codeforces 719A 月亮
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.
解法:
#include<stdio.h>
int main(){
int n,i;
int a[];
while(scanf("%d",&n)){
for(i=;i<n;i++)
scanf("%d",&a[i]);
if(n==&&a[n-]!=&&a[n-]!=)
printf("-1\n");
else if(a[n-]==) printf("DOWN\n");
else if(a[n-]==) printf("UP\n");
else if(a[n-]<&&a[n-]<a[n-])
printf("UP\n");
else if(a[n-]<&&a[n-]>a[n-])
printf("DOWN\n");
}
return ;
}
Codeforces 719A 月亮的更多相关文章
- 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
Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he go ...
- CodeForces 719A Vitya in the Countryside (水题)
题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, & ...
- 【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水题集合[14/未完待续]
Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...
- Codeforces Round #373 (Div. 2)A B
Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 这回做的好差啊,a想不到被hack的数据,b又没有想到正确的思维 = = [题目链 ...
- Codeforces 989 P循环节01构造 ABCD连通块构造 思维对云遮月参考系坐标轴转换
A 直接判存不存在连续的三个包含A,B,C就行 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a ...
随机推荐
- abbix通过JMX监控Tomcat(被监控端安装Tomat的服务器防火墙策略iptables配置)
原文地址:http://jaychang.iteye.com/blog/2214830 一.目前的环境 被监控端192.168.153.191 /usr/local/tomcat 下载了catalin ...
- 无线网络中信噪比(SNR)计算
信噪比(S/N)=log[信号功率密度/噪声功率密度] a =log[信号功率密度]-log[噪声功率密度] 例如,接收端的信号功率密度为-63dBm,噪声的信号功率密度为-95dBm,则: 信噪比( ...
- 旋转数组的最小数字 - 剑指offer 面试题8
题目描述: 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转.输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素.例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋 ...
- 新浪2017校园招聘---C++后台研发
一共10道题目,难度不大,就是题量大,时间短. 1. 编程 写一个函数,求出一字符串的所有排列. 2. 编程 实现一个在32位系统下把字符串转换成浮点数的函数 floa ...
- Hadoop生态的配置
网盘下载地址 链接: https://pan.baidu.com/s/19qWnP6LQ-cHVrvT0o1jTMg 密码: 44hs Hadoop伪分布式配置 Hadoop 可以在单节点上以伪分布 ...
- Linq sum()时遇到NULL
当使用linq求和sum()时,如果某列数据为null,就会出现异常 使用下面的语句即可解决相关问题: db.TableModel.Where(w => w.ID == ID).Select(s ...
- Day14 Python基础之os/sys/hashlib模块(十二)
os模块 os.getcwd() #获取当前工作路径 os.chdir(‘dirname1/dirname2/dirname3’) #改变当前脚本的工作路径,相当于cmd下的cd os.makedi ...
- 帮助小白,最新版JDK的安装与环境变量配置(Win 10系统)
学习JAVA,必须首先安装一下JDK(java development kit java开发工具包),之后再配置环境变量就可以开始使用JAVA了. 一,安装JDK 1,可以选择到官网下载最新版本的JD ...
- Display Hibernate SQL to console – show_sql , format_sql and use_sql_comments
(转)灵活控制 Hibernate 的日志或 SQL 输出,以便于诊断 - CS408 - 博客园 https://www.cnblogs.com/lixuwu/p/7479496.html Disp ...
- 关于PHP批量图片格式转换的问题--本文转成webp, 其他过程格式一样
最近要把项目中的图片全部生成webp格式, 过程整理一下, (直接存在本地,或者图片链接存在数据库都可以看看) 首先,肯定是批量处理, 一个php处理不了这么多, 会爆内存的, 个人建议用aja ...