想麻烦了。这题真的那么水啊。。直接暴力模拟,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. 【poj2891】Strange Way to Express Integers

    题意: 给出n个模方程x=a(mod r) 求x的最小解 题解: 这就是个线性模方程组的模版题- - 但是有一些要注意的地方 extgcd算出来的解x可能负数  要让x=(x%mo+mo)%mo 而且 ...

  2. [学姿势]使用AngularJS+CodeIgniter框架经验谈

    这篇文章作为总结总结7月份参与项目时遇到的新东西和问题,包括这两个框架(CodeIgniter.AngularJS)以及两个功能实现.有前端调试显示动态认证,也有用php实现功能模块. 1.添加设备 ...

  3. HDU 5710 Digit-Sum (构造)

    题意: 定义S(N) 为数字N每个位上数字的和.在给两个数a,b,求最小的正整数n,使得 a×S(n)=b×S(2n). 官方题解: 这道题目的结果可能非常大,所以我们直接枚举n是要GG的. 首先可以 ...

  4. 很好用的mybatis分页解决方案

    分页如果写在SQL脚本中,将会大大影响我们后续数据库的迁移难度.mybatis的分页一般是自己实现一个mybatis的拦截器,然后根据某些特定的条件开启分页,对原有SQL进行改造. 正在我对mybat ...

  5. Java网络编程(模拟浏览器访问Tomcat服务器)

    程序运行结果: HTTP/1.1 404 Not FoundServer: Apache-Coyote/1.1Content-Type: text/html;charset=utf-8Content- ...

  6. Android实例-程序界面内截取屏幕(XE8+小米2)

    结果: 1.只能截取程序界面内的图片. 2.图片有点不清楚,自己设置清楚度. 实例代码: unit Unit1; interface uses System.SysUtils, System.Type ...

  7. Java经典面试题

    1. Java中的异常处理机制的简单原理和应用. 当Java 程序违反了Java的语义规则时,Java虚拟机就会将发生的错误表示为一个异常.违反语义规则包括2种情况.一种是Java类库内置的语义检查. ...

  8. PING命令入门详解(转载)

    本文转自http://www.linkwan.com/gb/tech/htm/928.htm 1.Ping的基础知识 ping命令相信大家已经再熟悉不过了,但是能把ping的功能发挥到最大的人却并不是 ...

  9. 爬取知乎百万信息之UrlTask

    这个模块的作用是从nexturl队列获取用户的关注列表的url,获取关注列表.服务器返回的Json的数据 封装一个对象的序列化和反序列化的类 public class SerializeHelper ...

  10. Java循环语句 for

    语法: 特点:相比 while 和 do...while 语句结构更加简洁易读 例如,输出 1000 遍"我爱慕课网",使用 for 的实现代码为: 需要留心的几个小细节: 1. ...