HDU 4928 Series 2
有了题解以后这题就成了一个模拟题。不过写了好久才把它写对…… 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的更多相关文章
- hdu 4928 Series 2 (优化+模拟)
题意: 一个含n个数的序列a,每两个相邻的数相减得到一个新数,这些数组成一个新的序列. 假设全部得到的序列都满足非严格的单调性.则原序列为nice series.假设给出的序列 本来不满足单调性.它是 ...
- HDU 4927 Series 1(推理+大数)
HDU 4927 Series 1 题目链接 题意:给定一个序列,要求不断求差值序列.直到剩一个,输出这个数字 思路:因为有高精度一步.所以要推理一下公式,事实上纸上模拟一下非常easy推出公式就是一 ...
- 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 ...
- HDU 4927 Series 1 ( 组合+高精度)
pid=4927">Series 1 大意: 题意不好翻译,英文看懂也不是非常麻烦,就不翻译了. Problem Description Let A be an integral se ...
- 2014多校第六场 1007 || HDU 4927 Series 1(杨辉三角组合数)
题目链接 题意 : n个数,每操作一次就变成n-1个数,最后变成一个数,输出这个数,操作是指后一个数减前一个数得到的数写下来. 思路 : 找出几个数,算得时候先不要算出来,用式子代替,例如: 1 2 ...
- BUPT2017 wintertraining(15) #2 题解
这场有点难,QAQ.补了好久(。• ︿•̀。) ,总算能写题解了(つд⊂) A. Beautiful numbers CodeForces - 55D 题意 求\([l,r](1\le l_i\l ...
- 【HDU - 4927】Series 1
BUPT2017 wintertraining(15) #5I 题意 输出序列A[1..n]的第n-1阶差分(一个整数). 题解 观察可知答案就是 \[ \sum_{i=0}^{n-1} {(-1)^ ...
- HDU 4757 Tree(可持久化Trie+Tarjan离线LCA)
Tree Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others) Total Su ...
- HDU 1264 Counting Squares(线段树求面积的并)
Counting Squares Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- Epplus做Excel的数据透视
//表格的范围需要自己定义 var epplus = new ExcelPackage(); var sheet = epplus.Workbook.Worksheets.Add("Shee ...
- 【原创】Linux下的ngix服务器安装步骤
1.首先下载ngix的源码linux版本[1.5.8版本] http://nginx.org/en/download.html 2.下载PCRE library,是安装ngix的必备包之一 [root ...
- 设置IE浏览器文档模式版本
浏览器版本问题是所有开发web的程序员共同的诟病,尤其是IE浏览器,笔者上次修改公司的一个项目中出现项目是在IE9没有出来之前,而现在修改时,则发现页面上出现的表格的错乱(因为表格是通过js动态生成的 ...
- [AHOI2013]作业 莫队 树状数组
#include<cmath> #include<cstdio> #include<algorithm> #include<string> #inclu ...
- BZOJ 1594 [Usaco2008 Jan]猜数游戏(线段数)
1594: [Usaco2008 Jan]猜数游戏 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 626 Solved: 260[Submit][S ...
- java 模拟ajax上传图片
1.maven 引入依赖 <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime --> &l ...
- 紫书 习题 8-13 UVa 10570 (枚举+贪心)
我看到数据范围只有500, 第一反应枚举所有的可能,然后求出每种可能的最小次数. 但是不知道怎么求最小次数.我想的是尽量让一次交换可以让两个不在应该在的位置的数字 到原来应该在的位置的数字, 这样可以 ...
- 【CS round 34】Minimize Max Diff
[题目链接]:https://csacademy.com/contest/round-34/task/minimize-max-diff/ [题意] 给你n个数字; 数组按顺序不下降; 让你删掉k个数 ...
- crazyradio焊接和下载固件过程
非常早之前买过一套crazyradio的器件和空板.可是一直没有时间焊接出来,前天早上六点起来,安静的弄了一把,识别USB.下载crazyradio固件没问题,记录下过程: 1,首先是焊接,寻常的QF ...
- SPOJ 题目705 New Distinct Substrings(后缀数组,求不同的子串个数)
SUBST1 - New Distinct Substrings no tags Given a string, we need to find the total number of its di ...