有了题解以后这题就成了一个模拟题。不过写了好久才把它写对…… Sad

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <time.h> using namespace std; typedef __int64 ll; const int INF = <<;
const int MAXN = (int) 1e5+; ll a[MAXN];
int n; inline int check(ll A[], int len) {
bool INC = true, DEC = true;
for (int i = ; i < len-; i++)
if (A[i+]>A[i]) INC = false;
else if (A[i+]<A[i]) DEC = false;
return INC||DEC;
} int solve() {
int cur = ;
int l = , r = n-;
for (int i = ; i < n; i++) {
while (l<r && a[l]==) l++;
while (l<r && a[r]==) r--;
l = max(, l-);
r = min(r+, n-i); if (!check(a+l, r-l)) return i; for (int j = l; j < r; j++)
a[j] = a[j+]-a[j];
r--;
}
return n;
} int main() {
#ifdef Phantom01
freopen("HDU4928.txt", "r", stdin);
#endif //Phantom01 int T;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i = ; i < n; i++)
scanf("%I64d", &a[i]);
int ans = solve();
if (==ans) puts("ugly series");
else if (n==ans) puts("nice series");
else printf("%d\n", ans-);
} return ;
}

HDU 4928 Series 2的更多相关文章

  1. hdu 4928 Series 2 (优化+模拟)

    题意: 一个含n个数的序列a,每两个相邻的数相减得到一个新数,这些数组成一个新的序列. 假设全部得到的序列都满足非严格的单调性.则原序列为nice series.假设给出的序列 本来不满足单调性.它是 ...

  2. HDU 4927 Series 1(推理+大数)

    HDU 4927 Series 1 题目链接 题意:给定一个序列,要求不断求差值序列.直到剩一个,输出这个数字 思路:因为有高精度一步.所以要推理一下公式,事实上纸上模拟一下非常easy推出公式就是一 ...

  3. HDU 4927 Series 1(高精度+杨辉三角)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4927 解题报告:对于n,结果如下: C(0,n-1) *A[n] - C(1,n-1) * A[n-1 ...

  4. HDU 4927 Series 1 ( 组合+高精度)

    pid=4927">Series 1 大意: 题意不好翻译,英文看懂也不是非常麻烦,就不翻译了. Problem Description Let A be an integral se ...

  5. 2014多校第六场 1007 || HDU 4927 Series 1(杨辉三角组合数)

    题目链接 题意 : n个数,每操作一次就变成n-1个数,最后变成一个数,输出这个数,操作是指后一个数减前一个数得到的数写下来. 思路 : 找出几个数,算得时候先不要算出来,用式子代替,例如: 1 2 ...

  6. BUPT2017 wintertraining(15) #2 题解

    这场有点难,QAQ.补了好久(。• ︿•̀。) ,总算能写题解了(つд⊂) A. Beautiful numbers CodeForces - 55D 题意 ​ 求\([l,r](1\le l_i\l ...

  7. 【HDU - 4927】Series 1

    BUPT2017 wintertraining(15) #5I 题意 输出序列A[1..n]的第n-1阶差分(一个整数). 题解 观察可知答案就是 \[ \sum_{i=0}^{n-1} {(-1)^ ...

  8. HDU 4757 Tree(可持久化Trie+Tarjan离线LCA)

    Tree Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others) Total Su ...

  9. HDU 1264 Counting Squares(线段树求面积的并)

    Counting Squares Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

随机推荐

  1. web语义化理解

    含义: Web语义化是指使用语义恰当的标签,使页面有良好的结构,页面元素有含义,能够让人和搜索引擎都容易理解. 为什么要web语义化?如今互联网都到了web2.0的时代了,HTML语言在不断的进化并发 ...

  2. NEON基本知识

    http://blog.csdn.net/EmSoftEn/article/details/51834171 http://blog.csdn.net/yxnyxnyxnyxnyxn/article/ ...

  3. sqlserver 恢复模式及避免日志爆满的方法

    recovery simple 循环日志,空间自动回收,不可备份日志,恢复时仅能恢复到数据库备份时间点: 用于落地数据或测试环境或OLAP,不推荐用于生产OLTP 有时候distribution过大也 ...

  4. SpringCloud学习笔记(4)----Spring Cloud Netflix之Eureka的配置

    1. Eureka监控配置 Eureka的客户端需要加入依赖 <dependency> <groupId>org.springframework.boot</groupI ...

  5. FCC编程题之中级算法篇(中)

    介绍 接着上次的中级算法题 目录 1. Missing letters 2. Boo who 3. Sorted Union 4. Convert HTML Entities 5. Spinal Ta ...

  6. 洛谷P3369 【模板】普通平衡树 01trie/骚操作

    Code: #include <cstdio> #include <algorithm> #include <cstring> #define setIO(s) f ...

  7. tinymce原装插件源码分析(四)-fullscreen

    fullscreen 作为一款文本编辑器,全屏功能是非常有必要的.在插件中主要是修改一些css style和触发resize事件. style问题(反例): 见github源码:https://git ...

  8. 3步简单实现SSH无密码登录

    下面简单的做下实验: 一:准备2台服务器: 192.168.10.101 2 192.168.10.102 二:关键字解释 ssh-keygen :  产生公钥与私钥对 ssh-copy-id :将本 ...

  9. unity3D常见问题

    总结自己在学习中遇到的问题. 记录问题,帮助他人,有什么不正确的地方欢迎指正 没有发生碰撞 两个物体(Plane和Cube)都加入了collider,当中一个加入了rigidbody,应该会产生碰撞, ...

  10. [Javascript] String Padding in Javascript using padStart and padEnd functions

    ES2017 added two new string functions. They are padStart and padEndfunctions. In this lesson, we wil ...