(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 ...
随机推荐
- 2015 南阳ccpc The Battle of Chibi (uestc 1217)
题意:给定一个序列,找出长度为m的严格递增序列的个数. 思路:用dp[i][j]表示长度为i的序列以下标j结尾的总个数.三层for循环肯定超时,首先离散化,离散化之后就可以用树状数组来优化,快速查找下 ...
- android EditText设置光标、边框和图标
控制边框形状,先在drawable中建一个xml文件:shape.xml <?xml version="1.0" encoding="utf-8"?> ...
- HttpClient 发送图片
var httpClient = new HttpClient(); using (FileStream fs = new FileStream("C:\\1.jpg", File ...
- sql 学习笔记 p46
交换行 update tab1 set c1=c2,c2=c1 .说明sql是临时表的存储,在查询出来的结果为决定前,可以随意操纵临时表中的列 update tab set c1=c1+(selec ...
- C#接口的使用
.接口: 接口与抽象类一样,也是表示某种规则,一旦使用了该规则,就必须实现相关的方法.对于C#语言而言,由于只能继承自一个父类,因此若有多个规则需要实现,则使用接口是个比较好的做法. .接口的定义 i ...
- Objective-C 类,函数调用
// // main.m // L02HelloObjC // // Created by JinXin on 15/11/25. // Copyright © 2015年 JinXin. All r ...
- Swift - 16 - String.Index和Range
//: Playground - noun: a place where people can play import UIKit var str = "Welcome to Play Sw ...
- 使用第三方SDK出现: duplicate symbol _llvm.cmdline in:
如果是同一个静态库中的文件链接的时候有冲突,可能是这个静态库不支持模拟器,真机运行就好了. 或者可以使用xcode7的虚拟机跑也是没问题的. duplicate symbol _llvm.cmdlin ...
- 跟我学android-Notification
Notification 可以理解为通知的意思,会出现在通知栏,比如来了一条短信 使用 Notification 有以下3个步骤: 1. 创建 NotificationManager的对象 2.为No ...
- css expression explaination
http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx 据说已经被弃用的IE css写法,为了修复一些IE8及老版本 ...