【UVA】1594 Ducci Sequence(纯模拟)
题目
分析
真的快疯了,中午交了一题WA了好久,最后发现最后一个数据不能加\n,于是这次学乖了,最后一组不输出\n,于是WA了好几发,最后从Udebug发现最后一组是要输出的!!!
代码
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n,a[25];
bool s()
{
for(int i=0;i<n;i++)
if(a[i]!=0) return false;
return true;
}
int main()
{
int t;
// freopen("1.txt","w",stdout);
scanf("%d",&t);
while(t--){
int flag=0;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=1;i<=1001;i++)
{
if(s()) { flag=1; break; }
int top=a[0];
for(int j=0;j<n-1;j++)
{
a[j]=abs(a[j]-a[j+1]);
}
a[n-1]=abs(a[n-1]-top);//a[0]被修改过了,只能用top
}
if(flag==1) printf("ZERO\n");
else printf("LOOP\n");
}
return 0;
}
【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
想麻烦了.这题真的那么水啊..直接暴力模拟,1000次(看了网上的200次就能A)后判断是否全为0,否则就是LOOP: #include <iostream> #include <s ...
- Uva - 1594 - Ducci Sequence
水题,算出每次的结果,比较是否全0,循环1000次还不是全0则LOOP AC代码: #include <iostream> #include <cstdio> #include ...
- 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 ...
- [刷题]算法竞赛入门经典(第2版) 5-2/UVa1594 - Ducci Sequence
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,20 ms) //UVa1594 - Ducci Sequence #include< ...
- UVa 1584 Circular Sequence --- 水题
UVa 1584 题目大意:给定一个含有n个字母的环状字符串,可从任意位置开始按顺时针读取n个字母,输出其中字典序最小的结果 解题思路:先利用模运算实现一个判定给定一个环状的串以及两个首字母位置,比较 ...
随机推荐
- root用户下使用sqlplus登录Oracle数据库
1.把环境变量添加到root用户的环境变量里面2.执行 chmod -R 6777 /tmp chmod -R 6777 /usr/tmp chmod -R 6 ...
- Android SDK无法更新解决办法
一.设置SDK代理 启动Android SDK Manager,选择菜单 Tools ->Options -> 代理地址: mirrors.opencas.cn 代理端口: 80 如下图: ...
- jfreechart 在jsp页面显示所画的图片(resin服务器的servelet配置是关键)(图片只过内存)
用的web服务器是resin服务器,在配置web.xml时需要注意,其实resin服务器的web.xml服务器配置和tomcat服务器的配置很像, 1. 我第一次按照自己的想法,想当然的在resin- ...
- Vim技能修炼教程(12) - Vim的脚本语言支持
Vim的脚本语言支持 本节开始,我们正式接触vimscript这门古老的脚本语言. 首先要说明,vim支持的扩展语言很多,比如python, python3, ruby, lua,tcl等常见脚本语言 ...
- RxJava 1.x 笔记:创建型操作符
本篇文章是阅读 官方文档 的笔记. 作者:shixinzhang(百度搜索 "shixinzhang CSDN" 即可找到我) RxJava 也用了有段时间,那么多操作符总不想去记 ...
- ss-libev 源码解析local篇(3): server_recv_cb之SNI和STAGE_PARSE
上一篇看到STAGE_HANDSHAKE中的处理,到发出fake reply.这之后会从socks5 request中解析出remote addr and port,即客户端实际想要访问的服务器地址和 ...
- linux 系统优化+定时任务
安装软件 通过yum安装 自动补全工具:yum completion yum install -y tree bash-completion wget vim find -[TAB] 更改系统的yum ...
- Linux 交换eth0和eth1
一.参考文档: 如何交换eth0和eth1? http://bbs.chinaunix.net/archiver/tid-2026056.html 二.具体操作 #echo `ifconfig -a` ...
- java之接口
背景 为了防止[多重继承]:(在面向对象的编程语言(例如java)中,指一个类可以同时继承多个父类的行为和特征功能)所引发的"致命方块",出现了接口. 使用 定义 public ...
- ICCS 会议 Latex 压缩文件提交主要事项
cd papers/conf latex main... check that the are no error messages ...zip -r mypaper.zip * 说明:必须在Linu ...