【习题 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 ( ...
随机推荐
- 82.QT实现委托构造
#include "mainwindow.h" #include <QApplication> //创建一个MainWindow类 class myclass { pr ...
- button按钮下边框有立体效果样式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Vue 国家省市三级联动
在网上查阅一下,基本上是省市区三级联动,国家省市的就只能自己动手了. 样式就根据自己的需要去调整了. JSON数组太长,就折叠放在了后面. 效果图: <!DOCTYPE html> < ...
- 关于Blocking IO,non-Blokcing IO,async IO的区别和理解
来源:http://shmilyaw-hotmail-com.iteye.com/blog/1896683 概括来说,一个IO操作可以分为两个部分:发出请求.结果完成.如果从发出请求到结果返回,一直B ...
- [TypeScript] Model Alternatives with Discriminated Union Types in TypeScript
TypeScript’s discriminated union types (aka tagged union types) allow you to model a finite set of a ...
- 通过wireshark,以及python代码收发邮件,了解smtp协议,pop协议工作过程
40返回连接server成功 41.43发送ehlo命令查询server支持命令 返回250 44.46请求认证 server响应235认证成功 47.49发送mail命令发送者邮箱 返回250 ...
- LINUX下为apache 和 PHP 添加模块
LINUX下为apache 和 PHP 添加模块https://www.path8.net/tn/archives/4717/opt/lampp/bin/httpd -V/opt/lampp/bin/ ...
- pdnsd 解析原理
apt install dnsmasq dnsmasq-fullvim /etc/dnsmasq.conf vim /etc/pdnsd.conf killall pdnsdpdnsd -c /etc ...
- Android学习笔记进阶十三获得本地全部照片
这是Intent的一个用法. 在ActivityAction里面有一个“ACTION_GET_CONTENT”字符串常量,该常量让用户选择特定类型的数据. intent.setType("i ...
- select发生改变使用js提交form表单(get传值)
form表单如下: <form id="my_form" method="get" action=""> <input t ...