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], ...
随机推荐
- HttpServletRequest获取URL?后面的内容
获取URL?后面的内容 如https://i.cnblogs.com/EditPosts.aspx?opt=1 String para = request.getQueryString(): para ...
- super 关键字
- sqlserver批量更新数据
update t_hr_teadept set rjkm=b.yjkmfrom t_hr_teadept a inner join t_tr_bzxx_km b on a.bzh=b.bzh wher ...
- moment.js常用时间示例,时间管理
'今天': moment() '昨天': moment().subtract(1, 'days') '过去7天':moment().subtract(7, 'days'),moment() '上月': ...
- RabbitMQ用户管理
rabbitmq常用命令 add_user <UserName> <Password> delete_user <UserName> chan ...
- struts框架从.jsp页面直接访问action
<%@ page language="java" pageEncoding="UTF-8"%><%String path = request. ...
- 【ASP.NET Core】给中间件传参数的方法
最近博客更新频率慢了些,原因有三: 其一,最近老周每星期六都录 ASP.NET Core 的直播,有些内容在视频里讲过,就不太想在博客里面重复.有兴趣的话可以去老周的微博看,或者去一直播,直播帐号与微 ...
- Python自动化测试入门
在当前自动化测试中,最火的语言就是Python,很容易上手.然后就是Java+testng+appium做的UI自动化测试.下面我们就用Python脚本,做自动化集成测试. (1)获取APK文件中ID ...
- Nginx 配置HTTPS 与Node.js 配置HTTPS方法
前段时间公司网站要求加上HTTPS安全CA证书,公司服务器全是阿里云服务器,并且配有负载均衡,所以选择直接在阿里云购买CA证书,阿里云有一种证书可以免费试用一年,决定申请此证书,阿里云证书需要验证,阿 ...
- machine learning 之 Neural Network 1
整理自Andrew Ng的machine learning课程week 4. 目录: 为什么要用神经网络 神经网络的模型表示 1 神经网络的模型表示 2 实例1 实例2 多分类问题 1.为什么要用神经 ...