【习题 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 ( ...
随机推荐
- php中str_repeat函数
php中str_repeat函数 一.作用 用于repeat str 二.实例:输出菱形 代码: <!DOCTYPE html> <html lang="en"& ...
- Hyperic
https://my.oschina.net/hyperichq/blog/525590
- 华为畅玩5 (CUN-AL00) 刷入第三方twrp Recovery 及 root
华为畅玩5 (CUN-AL00) 刷入第三方twrp Recovery 及 root 下载地址 http://pan.baidu.com/s/1hsn6VzA 1. 在官网申请解锁码 申 ...
- TimePickerDialog -下划线颜色修改
首先就是去framework下去找与之相关的theme属性 最开始的时候,直接找的是<item name="datePickerStyle">@style/Widget ...
- [BZOJ2238]Mst 最小生成树+树链剖分/并查集
链接 题解 先构建出最小生成树,如果删的是非树边,直接输出答案 否则问题转化为,把该边删掉后剩下两个联通块,两个端点分别在两个块内的最小边权,LCT可以维护 不妨换一种思考方向:考虑一条非树边可以代替 ...
- .Net Standard和各平台关系
.NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 .NET 核心 1.0 1.0 1.0 1.0 1.0 1 ...
- Mahout是什么?(一)
不多说,直接上干货! http://mahout.apache.org/ Mahout是Apache Software Foundation(ASF)旗下的一个开源项目. 提供一些可扩展的机器学习领域 ...
- 使用STS新的工作空间无需再配置
在你的新的工作空间中找到比如 F:\java-wokespace\你的新的工作空间名称\.metadata\.plugins\org.eclipse.core.runtime\.settings 找到 ...
- carousel轮播器
<div id="myCarousel" class="carousel slide" data-ride="carousel" st ...
- canvas和svg区别
什么是 Canvas? HTML5 的 canvas 元素使用 JavaScript 在网页上绘制图像. 画布是一个矩形区域,您可以控制其每一像素. canvas 拥有多种绘制路径.矩形.圆形.字符以 ...