Uva - 1594 - Ducci Sequence
水题,算出每次的结果,比较是否全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的更多相关文章
- uva 1594 Ducci Sequence <queue,map>
Ducci Sequence Description A Ducci sequence is a sequence of n-tuples of integers. Given an n-tupl ...
- UVA 1594 Ducci Sequence(两极问题)
Ducci Sequence Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu D ...
- 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, · · · ...
- 【暴力模拟】UVA 1594 - Ducci Sequence
想麻烦了.这题真的那么水啊..直接暴力模拟,1000次(看了网上的200次就能A)后判断是否全为0,否则就是LOOP: #include <iostream> #include <s ...
- 【UVA】1594 Ducci Sequence(纯模拟)
题目 题目 分析 真的快疯了,中午交了一题WA了好久,最后发现最后一个数据不能加\n,于是这次学乖了,最后一组不输出\n,于是WA了好几发,最后从Udebug发现最后一组是要输出的!!! ...
- UVa----------1594(Ducci Sequence)
题目: 1594 - Ducci Sequence Asia - Seoul - 2009/2010A Ducci sequence is a sequence of n-tuples of inte ...
- Ducci Sequence UVA - 1594
A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1,a2,···,an ...
- LIS UVA 10534 Wavio Sequence
题目传送门 题意:找对称的,形如:123454321 子序列的最长长度 分析:LIS的nlogn的做法,首先从前扫到尾,记录每个位置的最长上升子序列,从后扫到头同理.因为是对称的,所以取较小值*2-1 ...
- uva 10534 Wavio Sequence LIS
// uva 10534 Wavio Sequence // // 能够将题目转化为经典的LIS. // 从左往右LIS记作d[i],从右往左LIS记作p[i]; // 则最后当中的min(d[i], ...
随机推荐
- mongodb数据库备份迁移 windows -> linux
mongodb数据库备份迁移 windows -> linux cd 到本机mongodb的安装目录 如: C:\Program Files\MongoDB\Server\3.4\bin 可以发 ...
- 基于无域故障转移群集 配置高可用SQLServer 2016数据库
基于上次的文章搭建的环境,可以在这里:http://www.cnblogs.com/DragonStart/p/8275182.html看到上次的文章. 演示环境 1. 配置一览 Key Value ...
- Oracle中查询和删除相同记录的3种方法
--创建测试表 )); ,'); ,'); ,'); ,'); ,'); ,'); commit; select * from test; --查询相同记录 ); select id,name fro ...
- 跟着大佬重新入门DP
数列两段的最大字段和 POJ2479 Maximum sum Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 41231 Acce ...
- AnyConnect使用说明(手机版)
一.下载安装客户端 iPhone手机在App Store 里搜索 “Anyconnect”下载安装. Android手机需另外下载Anyconnect. 二. 1.打开AnyConnect,点击&qu ...
- Node.js 网络
稳定性: 3 - 稳定 net 模块提供了异步网络封装,它包含了创建服务器/客户端的方法(调用 streams).可以通过调用 require('net') 包含这个模块. net.createSer ...
- Java第9次实验(网络)
参考资料 本次作业参考文件 正则表达式参考资料 注:主要根据实验任务书的指导完成本次实验. 第1次实验 1. 网络基础 ipconfig.ping telnet(连接BBS与连接Web服务器的不同) ...
- Android动态修改ToolBar的Menu菜单
Android动态修改ToolBar的Menu菜单 效果图 实现 实现很简单,就是一个具有3个Action的Menu,在我们滑动到不同状态的时候,把对应的Action隐藏了. 开始上货 Menu Me ...
- FindBugs入门简介(eclipse安装使用实例)
前言:一般公司都会有一些开发规范,但是事实上,简单看那么一两遍并不能养成习惯,或者将这些规范记住.特别的,对于一些新手,写的代码往往会很糟糕.回头看看你一两年前写的代码就会知道,所谓的"糟糕 ...
- Xcode在playground的quick look框中显示对象自定义视图
对于一般对象,playground中默认的quick look显示已经够用,比如简单的字符串,Int,或简单的自定义Class等等. 不过对于有些情况,我们需要自定义对象在playground中的显示 ...