想麻烦了。这题真的那么水啊。。直接暴力模拟,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. Open-Drain V.S. Push-Pull

    作者:crifan (http://bbs.chinaunix.net)邮箱:green-waste@163.com [Open-Drain与Push-Pull]GPIO的功能,简单说就是可以根据自己 ...

  2. MultiByteToWideChar和WideCharToMultiByte用法详解

    今天写ini文件的时候发现的问题: TCHAR temp[]; //strcpy_s(temp, request.newVersion); MultiByteToWideChar(CP_ACP, , ...

  3. window2008 64位系统没有office组件问题分析及解决

    服务器是windows server2008 64位系统, 我的系统需要用到Microsoft.Office.Interop.Excel组件 在上传Excel单据遇到错误:检索 COM 类工厂中 CL ...

  4. HW6.6

    public class Solution { public static void main(String[] args) { int[] prime = new int[50]; prime[0] ...

  5. HDU-2262 Where is the canteen 概率DP,高斯消元

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2262 题意:LL在一个迷宫里面转,每次走向周围能走的点的概率都是一样的,现在LL要随机的走到cante ...

  6. Ubunut 13.04下配置memcached、 python MySQLDB,python-memcache模块等

    一开始系统使用的是163的源,没有安装成功memcached,换了cn99的也不行,后来换了台湾的源,以下步骤才得以顺利进行. 更换源的方法可以参看我以前的帖子. 安装memached:sudo ap ...

  7. 50个Java多线程面试题

    不管你是新程序员还是老手,你一定在面试中遇到过有关线程的问题.Java 语言一个重要的特点就是内置了对并发的支持,让 Java 大受企业和程序员的欢迎.大多数待遇丰厚的 Java 开发职位都要求开发者 ...

  8. [iOS基础控件 - 3.4] 汤姆猫

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...

  9. Objective-C Runtime 运行时之五:协议与分类

    Objective-C中的分类允许我们通过给一个类添加方法来扩充它(但是通过category不能添加新的实例变量),并且我们不需要访问类中的代码就可以做到. Objective-C中的协议是普遍存在的 ...

  10. 转载 SharePoint【Site Definition 系列】– 创建Content Type

    转载原地址:  http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面 ...