想麻烦了。这题真的那么水啊。。直接暴力模拟,1000次(看了网上的200次就能A)后判断是否全为0,否则就是LOOP;

 #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <iomanip> using namespace std;
#define INF 0x7fffffff
#define eps 1e-5
const int maxn = ;
const int maxl = ;
int a[maxn], vis[maxn];
int n;
bool Judge(int k)
{
bool zero = false;
for(int i = ; i <= n; i++)
{
if(a[i] && a[i] != k)
return ;
if(!a[i]) zero = true;
// printf("%d ", a[i]);
}
if(zero) return ;
else return ;
} int main()
{
int T;
scanf("%d", &T);
while(T--)
{
memset(vis, , sizeof(vis));
memset(a, , sizeof(a));
int cnt = ;
scanf("%d", &n);
for(int i = ; i <= n; i++)
scanf("%d", &a[i]);
a[n+] = a[];
int cur = , zero = ;
while(cur <= )
{
// cout << "----" <<endl; for(int i = ; i <= n; i++)
{
a[i] = abs(a[i]-a[i+]);
}
a[n+] = a[];
//cout << num << endl;
zero = ;
for(int i = ; i <= n; i++)
if(!a[i])
zero++; // cout << num << endl;
if(zero == n)
{
printf("ZERO\n");
zero = -;
break;
}
cur++;
} if(zero != -) printf("LOOP\n");
}
return ;
}

【暴力模拟】UVA 1594 - Ducci Sequence的更多相关文章

  1. UVA 1594 Ducci Sequence(紫书习题5-2 简单模拟题)

    A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, · · · ...

  2. UVA 1594 Ducci Sequence(两极问题)

           Ducci Sequence Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   D ...

  3. uva 1594 Ducci Sequence <queue,map>

    Ducci Sequence Description   A Ducci sequence is a sequence of n-tuples of integers. Given an n-tupl ...

  4. Uva - 1594 - Ducci Sequence

    水题,算出每次的结果,比较是否全0,循环1000次还不是全0则LOOP AC代码: #include <iostream> #include <cstdio> #include ...

  5. 【UVA】1594 Ducci Sequence(纯模拟)

    题目 题目     分析 真的快疯了,中午交了一题WA了好久,最后发现最后一个数据不能加\n,于是这次学乖了,最后一组不输出\n,于是WA了好几发,最后从Udebug发现最后一组是要输出的!!!   ...

  6. UVa----------1594(Ducci Sequence)

    题目: 1594 - Ducci Sequence Asia - Seoul - 2009/2010A Ducci sequence is a sequence of n-tuples of inte ...

  7. Ducci Sequence UVA - 1594

      A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1,a2,···,an ...

  8. [刷题]算法竞赛入门经典(第2版) 5-2/UVa1594 - Ducci Sequence

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,20 ms) //UVa1594 - Ducci Sequence #include< ...

  9. UVa 1584 Circular Sequence --- 水题

    UVa 1584 题目大意:给定一个含有n个字母的环状字符串,可从任意位置开始按顺时针读取n个字母,输出其中字典序最小的结果 解题思路:先利用模运算实现一个判定给定一个环状的串以及两个首字母位置,比较 ...

随机推荐

  1. NIOP1995 石子合并(区间DP)

    状态转移方程在代码中标出 本题注意是圆形,所以之前要预先处理一下s数组.处理之后总长度为2*n-1.第一个合并的起点有n个,所以总的方案数是n 注释在代码中标出 http://www.rqnoj.cn ...

  2. uvalive 4992 Jungle Outpost

    题意:一个凸边型,目标在凸边型内且最优.问最多删除几个点使目标暴露在新凸边型外面. 思路:二分+半平面相交. #include<cstdio> #include<cmath> ...

  3. [转载]mac下homebrew的使用

    该文转自:https://www.zybuluo.com/phper/note/87055 mac系统也是基于unix的系统,所以也继承类很多unix的特性,包括软件的编译,安装等.ubuntu下有快 ...

  4. A Tour of Go Mutating Maps

    Insert or update an element in map m: m[key] = elem Retrieve an element: elem = m[key] Delete an ele ...

  5. mssql触发器demo

    USE [pos]GO/****** Object: Trigger [dbo].[tr_insert] Script Date: 06/26/2014 09:27:19 ******/SET ANS ...

  6. iOS几个效果动画-------------------(实例详讲)qq粘性效果

    这几天做了一些简单iOS的效果图,感觉苹果官方已经帮我们做了很多了,我们只是站在巨人的肩膀上编程,这些也没什么难的,最难的也就是用到了初中的三角函数,先让大家看看这几个动画吧.先列这几个把,由上而下分 ...

  7. XML操作之Linq to Xml

    需要引用的命名空间:   using System.Xml.Linq; 常用的类:XDocument.XElement.XAttribute 创建 XDocument对象. XDocument.Loa ...

  8. LDO稳压器工作原理

    LDO稳压器工作原理 随着便携式设备(电池供电)在过去十年间的快速增长,像原来的业界标准 LM340 和LM317 这样的稳压器件已经无法满足新的需要.这些稳压器使用NPN 达林顿管,在本文中称其为N ...

  9. Hibernate映射文件简单配置

    <?xml version="1.0" ?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibe ...

  10. session和request的区别

    request 请求对象 请求中保存请求过程中需要的参数 比如另一个页面需要使用的对象编号,list,map等,请求结束,就失效了 session 会话对象 除非关闭会话(到时间通常为30分钟,或者关 ...