(1.1.9)UVA 10930 A-Sequence(模拟)
/*
* UVA_10930_1.cpp
*
* Created on: 2013年10月7日
* Author: Administrator
*/ #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int K[30001];
int main(){
int n;
int counter = 1;
while(scanf("%d",&n)!=EOF){ memset(K,0,sizeof(K));
int i,j;
printf("Case #%d:",counter++);
int w;
bool ok = true;
int last = 0;
K[0] = 1;//因为数字最小是从1开始的,所以将K[0]设为1,让0变为不可用
for(i = 1 ; i <= n ; ++i){
cin >> w;
cout<<" "<<w ; ok &= !K[w] && w > last; for(j = 10000 ; j >= w ; --j){
if(K[j - w]){
K[j] = 1;
}
}
last = w;
}
cout<<endl; cout<<"This is "<< ((ok)?"":"not ") <<"an A-sequence.";
cout<<endl; } return 0;
}
(1.1.9)UVA 10930 A-Sequence(模拟)的更多相关文章
- UVa 1584 Circular Sequence --- 水题
UVa 1584 题目大意:给定一个含有n个字母的环状字符串,可从任意位置开始按顺时针读取n个字母,输出其中字典序最小的结果 解题思路:先利用模运算实现一个判定给定一个环状的串以及两个首字母位置,比较 ...
- 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], ...
- 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 (模拟 Grade E)
题意: 对于一个n元组(a0,a1,...),一次变换后变成(|a0-a1|,|a1-a2|,...) 问1000次变换以内是否存在循环. 思路: 模拟,map判重 代码: #include < ...
- uva 10706 Number Sequence(数学规律)
题目连接:10706 - Number Sequence 题目大意:有一个有0 ~ 9组成的序列,1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 ....就是第一位为1. ...
- Codeforces 626A Robot Sequence(模拟)
A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- UVa 11210 - Chinese Mahjong 模拟, 枚举 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
随机推荐
- SPOJ 3943 - Nested Dolls 最长不下降子序列LIS(二分写法)
现在n(<=20000)个俄罗斯套娃,每个都有宽度wi和高度hi(均小于10000),要求w1<w2并且h1<h2的时候才可以合并,问最少能剩几个. [LIS]乍一看跟[这题]类似, ...
- ThinkPHP学习 volist标签高级应用之多重嵌套循环、隔行变色(转)
Action代码: public function index(){ $prod = I("get.prod_en"); $id = I("get.id", 0 ...
- IIS支持下载.config后缀名的文件
这里用.config举例,其他类型文件同理. 设置MIME点击右侧添加,文件扩展名填写.config,MIME类型填写application/octet-stream.或者添加.*,将所有未列出的文件 ...
- (转)Call to undefined function mb_convert_encoding()
需要先enable mbstring 扩展库 在 php.ini里将; extension=php_mbstring.dll 前面的 ; 去掉mb_convert_encoding 可以指定多种输入编 ...
- JAVA-4-斐波列
public class Ch049 { public static void main(String[] args) { // TODO 自动生成的方法存根 int a = 1, b = 1; fo ...
- jsp <%! %> 与 <% %> 区别
转自huangqiqing123.iteye.com/blog/1922014 <body> <%! //1.可定义方法 public String outMethod(){ ret ...
- The ultimate jQuery Plugin List(终极jQuery插件列表)
下面的文章可能出自一位奥地利的作者, 列出很多jQuery的插件.类似的网站:http://jquerylist.com/原文地址: http://www.kollermedia.at/archiv ...
- PL/SQL设置关键字大写
Tools->Preferences->User Interface->Keyword case = Uppercase,就设置为大写了.
- JS中break continue和return的用法?
在 break,continue和return 三个关键字中, break,continue是一起的,return 是函数返回语句,但是返回的同时也将函数停止 break和continue: 退出循环 ...
- gdb调试memcached
1.memcached安装前,要安装libevent 2.memcached在configure中 加上 CPPFLAGS='-ggdb3'选项 例如 本机 ./configure -prefix ...