水题,算出每次的结果,比较是否全0,循环1000次还不是全0则LOOP

AC代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

int ducci[20];

int main()
{
	int T;
	cin >> T;
	while (T--) {
		int n;
		cin >> n;
		// 记得清0
		memset(ducci, 0, sizeof(ducci));
		for (int i = 0; i < n; i++) {
			cin >> ducci[i];
		}
		int zero = 0, q = 0;
		// 循环1000次
		for (int i = 0; i < 1000; i++) {
			zero = 0;
			// 最后一个减去第一个的时候第一个已经改变了,所以先存储下来
			int t = ducci[0];
			for (int j = 0; j < n - 1; j++) {
				ducci[j] = abs(ducci[j] - ducci[j + 1]);
			}
			ducci[n - 1] = abs(ducci[n - 1] - t);
			// 判断是否全0
			for (int j = 0; j < n; j++) {
				if (ducci[j] == 0) {
					zero++;
				}
			}
			if (zero == n) {
				printf("ZERO\n");
				break;
			}
			if (i == 999) {
				printf("LOOP\n");
			}
		}

	}

	return 0;
}

Uva - 1594 - Ducci Sequence的更多相关文章

  1. uva 1594 Ducci Sequence <queue,map>

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

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

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

  3. 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, · · · ...

  4. 【暴力模拟】UVA 1594 - Ducci Sequence

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

  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. LIS UVA 10534 Wavio Sequence

    题目传送门 题意:找对称的,形如:123454321 子序列的最长长度 分析:LIS的nlogn的做法,首先从前扫到尾,记录每个位置的最长上升子序列,从后扫到头同理.因为是对称的,所以取较小值*2-1 ...

  9. uva 10534 Wavio Sequence LIS

    // uva 10534 Wavio Sequence // // 能够将题目转化为经典的LIS. // 从左往右LIS记作d[i],从右往左LIS记作p[i]; // 则最后当中的min(d[i], ...

随机推荐

  1. Nginx+tomcat配置集群负载均衡

    开发的应用采用F5负载均衡交换机,F5将请求转发给5台hp unix服务器,每台服务器有多个webserver实例,对外提供web服务和socket等接口服务.之初,曾有个小小的疑问为何不采用开源的a ...

  2. Jupyter notebook 输出含中文的pdf 方法

    我电脑 OS 是 Ubuntu14.04, 可用的最简单方法是: 打开终端,输入 sudo find / -name article.tplx 用以查找 article.tplx 文件位置,我电脑的结 ...

  3. Async分析

     1:android在新版本中不允许UI线程访问网络,但是如果需要访问网络又改怎么办呐?这里有很多解决方案,比如新开一个线程,在新线程中进行访问,然后访问数据,返回后可能会更新界面也可能不更新界面,这 ...

  4. vue.js-路由

    1:编写router.js   import Router from "vue-router" import Vue from "vue" import rou ...

  5. python学习之路web框架

    WEB框架的本质 python的WEB框架分为两大类: 1.自己写socket,自己处理请求 2.基于wsgi(Web Server Gateway Interface WEB服务网关接口),自己处理 ...

  6. 阿里云linux下web服务器配置

    markdown截图不方便,本教程不用markdown编写 首先参考文章 https://www.jianshu.com/p/2604e53a7f6a?from=singlemessage 安装完后无 ...

  7. 自定义Retrofit转化器Converter

    我们来看一下Retrofit的使用 interface TestConn { //这里的Bitmap就是要处理的类型 @GET("https://ss0.baidu.com/73F1bjeh ...

  8. ejabberd开发和部署

    ejabberd开发和部署 (金庆的专栏 2016.10) 搭建了自己的ejabberd集群,然后少量更改源码,实现定制的XMPP服务器. 从github fork ejabberd 库,定为 mas ...

  9. How to Collect Bne Log Files for GL Integrators

    In this Document   Goal   Solution APPLIES TO: Oracle General Ledger - Version 11.0 and laterInforma ...

  10. uboot-tiny4412启动流程(下)----如何将自己的裸板测试程序加入uboot中启动测试

    今天在工作上搞了一天高通的芯片uboot程序,目的是希望将一个裸板的程序移植到uboot中,并且开机让它运行.这个芯片是NXP4330,目前是高通的一个芯片,基于ARM-contexA9架构,那么就跟 ...