题目

题目

 


 

分析

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

 


 

代码

#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n,a[25];
bool s()
{
for(int i=0;i<n;i++)
if(a[i]!=0) return false;
return true;
}
int main()
{
int t;
// freopen("1.txt","w",stdout);
scanf("%d",&t);
while(t--){
int flag=0;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=1;i<=1001;i++)
{
if(s()) { flag=1; break; }
int top=a[0];
for(int j=0;j<n-1;j++)
{
a[j]=abs(a[j]-a[j+1]);
}
a[n-1]=abs(a[n-1]-top);//a[0]被修改过了,只能用top
}
if(flag==1) printf("ZERO\n");
else printf("LOOP\n");
}
return 0;
}

【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

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

  5. Uva - 1594 - Ducci Sequence

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

  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. 从头搭建一个React应用

    node,webpack这些就不一一介绍怎么安装了,默认大家都知道. 一.npm install -g create-react-app 首先全局安装react的脚手架工具 create-react- ...

  2. Win10 64bit下安装GPU版Tensorflow+Keras

    Tensorflow和Keras都是支持Python接口的,所以本文中说的都是搭建一个Python的深度学习环境. Keras是对Tensorflow或者Theano的再次封装,也就是以Tensorf ...

  3. 369C Valera and Elections

    http://codeforces.com/problemset/problem/369/C 树的遍历,dfs搜一下,从根节点搜到每个分叉末尾,记录一下路况,如果有需要修复的,就把分叉末尾的节点加入答 ...

  4. emacs编辑器的使用

    尽管有许多ide,但是,各种软件使用各种不同,设置等,受不了.觉得应该有一手好的编辑器就可以了.尤其是受不了ide什么lib,.h,exe,dll等路径设置,让人心烦.再加上黑盒子的感觉很不爽.一旦出 ...

  5. 【剑指offer】04A二维数组中的查找,C++实现

    1.题目 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数数组和一个整数,判断数组中是否含有该整数. 2.思路 首先选取数 ...

  6. hexo+github部署

    废话不多少,接着上次配置的环境进行github部署. 拥有自己的github 如果还没有github的账号就注册一个吧,传送门:GitHub官网:http://www.github.com 创建一个创 ...

  7. CF1130D Toy Train

    D Toy Train 开始时,对于一个点 \(x\) ,若没有糖果需要运走,则不考虑; 否则,若点上有 \(k\) 颗糖果需要运走,火车每次只能搭上 \(1\) 个,显然经过这个点至少 \(k\) ...

  8. Codeforces 1027E Inverse Coloring 【DP】

    Codeforces 1027E Inverse Coloring 题目链接 #include<bits/stdc++.h> using namespace std; #define N ...

  9. js中怎么去掉数组的空值

    for(var i = 0 ;i<array.length;i++)  {              if(array[i] == "" || typeof(array[i] ...

  10. 一款直接时空处理分析的开源数据库---geomesa

    一款直接时空处理分析的开源数据库---geomesa,可用于交通轨迹数据存储分析等相关领域, 在分布式列数据库的基础上进行扩展,目前支持Accumulo, HBase, Cassandra, and ...