CodeForces 719A Vitya in the Countryside 思维题

题目大意:月亮从0到15,15下面是0、循环往复。给出n个数字,如果下一个数字大于第n个数字输出UP,小于输出DOWN,无法确定输出-1.

题目思路:给出0则一定是UP,给出15一定是DOWN,给出其他的一个数字(n==1)无法确定,其他的情况比较后两位。

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstring>
 4 #include<vector>
 5 #include<stdio.h>
 6 #include<stdlib.h>
 7 #include<queue>
 8 #include<math.h>
 9 #include<map>
10 #define INF 0x3f3f3f3f
11 #define MAX 1000005
12 #define Temp 1000000000
13
14 using namespace std;
15
16 int a[MAX];
17 int main()
18 {
19     int n,op;
20     while(scanf("%d",&n)!=EOF)
21     {
22         for(int i=1;i<=n;i++)
23             scanf("%d",&a[i]);
24         if(n==1)
25         {
26             if(a[n]==15)
27                 op=-1;
28             else if(a[n]==0)
29                 op=1;
30             else
31                 op=0;
32         }
33         else
34         {
35             if(a[n]==15)
36                 op=-1;
37             else if(a[n]==0)
38                 op=1;
39             else if(a[n] > a[n-1])
40                 op=1;
41             else if(a[n] < a[n-1])
42                 op=-1;
43         }
44         if(op==0)
45             printf("-1\n");
46         else if(op==1)
47             printf("UP\n");
48         else
49             printf("DOWN\n");
50     }
51     return 0;
52 }

时间: 2024-07-28 14:52:56

CodeForces 719A Vitya in the Countryside 思维题的相关文章

CodeForces 719A Vitya in the Countryside (水题)

题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostr

贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

题目传送门 1 /* 2 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 3 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 4 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 5 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 6 */ 7 #include <cstdio> 8 #i

codeforces 848B Rooter&#39;s Song 思维题

http://codeforces.com/problemset/problem/848/B 给定一个二维坐标系,点从横轴或纵轴垂直于发射的坐标轴射入(0,0)-(w,h)的矩形空间.给出点发射的坐标轴,位置,延迟时间,发生碰撞则交换方向.求最后每个点的射出位置. 首先我们观察能得出两个结论,1. 类似蚂蚁爬树枝的问题,相遇只会交换方向,所以最后的射出点集只会因为碰撞而改变动点与射出点的对应关系,而不会增加减少射出点集.2.我们根据其射入位置和延迟时间可以计算出一个值v=pos-time,只有这

CodeForces 1131B(思维题)

You still have partial information about the score during the historic football match. You are given a set of pairs (ai,bi)(ai,bi), indicating that at some point during the match the score was "aiai: bibi". It is known that if the current score

Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round) A. Contest for Robots(思维题)

Polycarp is preparing the first programming contest for robots. There are nn problems in it, and a lot of robots are going to participate in it. Each robot solving the problem ii gets pipi points, and the score of each robot in the competition is cal

Unique Encryption Keys (思维题 预处理)

题目 题意:给m个数字, q次询问, 询问b到e之间如果有重复数字就输出, 没有就输出OK 思路:用f[i]数组 记录从i开始向后最近的有重复数字的 位置, 如 1 3 2 2, 则f[1] = 4; 如果离a最近的重复数字的位置 都大于b, 就说明没有重复数字. f[]数组需要预处理,从后向前. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <vector>

sdut 2847 Monitor (思维题)

题目 题意:给定a, b, x, y;  求使c, d; 使c:d = x :y; 且c<=a, d<=b, 而且c, d尽量大. 先求最小倍数, 再用最小倍数乘 x, y; 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 using namespace std; 6 7 long long gcd(long long a, l

hdu 4972 A simple dynamic programming problem (转化 乱搞 思维题) 2014多校10

题目链接 题意:给定一个数组记录两队之间分差,只记分差,不记谁高谁低,问最终有多少种比分的可能性 分析: 类似cf的题目,比赛的时候都没想出来,简直笨到极点..... 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <cmath> 6 #include <vector> 7 #include &

学习方法_2011年编写和锻炼的思维题

1.多看,多练,多想,多总结,最重要就是不停的写代码! 给自己的目标:一天代码量最少800行,无论是什么代码,如果练习的量不够,就重复做已经写过的代码. 思维题: 找出这当中数字 1,11,31,4113,612314 的规律是怎样的? 1,11,表示前面的数有1个131,表示前面所有的数有3个14113,表示前面的所有的数有4个1.1个3以此类推,前面所有的数有6个1.2个3.1个4,即为612314 1.两个无窗的房间,其中一间有三个电灯,另一间里面有三个开关,三个开关各控制三个电灯.问:每