【习题 5-2 UVA-1594】Ducci Sequence
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
map加vector轻松搞定。
【代码】
#include <bits/stdc++.h>
using namespace std;
typedef vector <int> Vi;
Vi v;
map <Vi,int> mmap;
int n;
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
int T;
scanf("%d", &T);
while (T--)
{
mmap.clear();
v.clear();
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
v.push_back(x);
}
while (!mmap[v])
{
mmap[v] = 1;
int temp = v[0];
for (int i = 0; i < n-1; i++) v[i] = abs(v[i] - v[i + 1]);
v[n - 1] = abs(v[n - 1] - temp);
}
int zero = 1;
for (int i = 0; i < n ; i++)
if (v[i] != 0)
zero = 0;
if (zero)
puts("ZERO");
else
puts("LOOP");
}
return 0;
}
【习题 5-2 UVA-1594】Ducci Sequence的更多相关文章
- 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(两极问题)
Ducci Sequence Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu D ...
- 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
水题,算出每次的结果,比较是否全0,循环1000次还不是全0则LOOP AC代码: #include <iostream> #include <cstdio> #include ...
- 【暴力模拟】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 ...
- UVa 1584 Circular Sequence --- 水题
UVa 1584 题目大意:给定一个含有n个字母的环状字符串,可从任意位置开始按顺时针读取n个字母,输出其中字典序最小的结果 解题思路:先利用模运算实现一个判定给定一个环状的串以及两个首字母位置,比较 ...
- Ducci Sequence
Description A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers ( ...
随机推荐
- gvim window7 下提示乱码
今天在win7下安装gvim的时候,发现所有的提示信息都是乱码的,在网上找到了如下的解决方案.在此记录下,方便以后查阅. 以下内容转载自http://blog.csdn.net/rehung/arch ...
- php intval函数
php intval函数 作用 intval — 获取变量的整数值 使用实例 <?php echo intval('-42'); // -42 ?> 相似函数 boolval() - 获取 ...
- Android引入library失败的可能原因
eclipse环境,引入library一直失败 谷歌到的原因是 Windows下 目标工程必须和引用工程在同一磁盘盘符下 然后我将要引入的library项目移动和现在项目同一磁盘下,引入成功 至于为什 ...
- c++位运算符介绍
下面是C/C++位操作运算符列表,其中运算符优先级为从上到下递减,但<<,>>优先级相同. C/C++位操作运算符 操作符 功能 用法 ~ 位求反 ~expr << ...
- Onvif开发之服务端成功对接Rtsp视频流篇
前面篇介绍onvif服务端的发现功能,继续在之前的代码基础上完成一个RTSP流的工作,也就是客户端通过ONVIF协议来预览设备端在这个之前必须确定几个简单的条件1 设备端能被发现2 设备端支持RTSP ...
- 33.IDEA + maven]在IDEA中打开一个maven项目,resolve完依赖后,缺少部分jar包问题
转自:https://www.cnblogs.com/zazalu/p/7649590.html [注意]作者只是对使用过程中遇到的问题提出了一个解决方案,但是本人在编写此解决方案文章的时候,对mav ...
- Cloudera Hue是什么?
Hue是cdh专门的一套web管理器,它包括3个部分hue ui,hue server,hue db.hue提供所有的cdh组件的shell界面的接口.你可以在hue编写mr,查看修改hdfs的文件 ...
- #学习笔记#——JavaScript 数组部分编程(四)
7.合并数组 arr1 和数组 arr2.不要直接修改数组 arr,结果返回新的数组 function concat(arr1, arr2) { return arr1.concat(arr2); } ...
- 将BT下载对抗到底
将BT下载对抗到底 随着互联网业务的多元化,各种P2P应用也越来越多,在企业中多数流量都会被类似于BT的下载所占用,BT之所以会危害到局域网,是因为它占用了大量网络带宽.网络管理员可以通过一 ...
- css3.0滚动条的优化
.ass_showFriends{width: 93%;height: 8.35rem;overflow-y: auto;} .ass_showFriends::-webkit-scrollbar{w ...