poj1989
一道非常神奇的题目
var v:array[0..10010] of boolean;
n,k,i,x,ans,s:longint;
begin
readln(n,k);
fillchar(v,sizeof(v),false);
ans:=1;
for i:=1 to n do
begin
readln(x);
if not v[x] then
begin
inc(s);
if s=k then
begin
fillchar(v,sizeof(v),false);
inc(ans);
s:=0;
end
else v[x]:=true;
end;
end;
writeln(ans);
end.
稍微想想就明白了
poj1989的更多相关文章
- [USACO2004][poj1989]The Cow Lineup(乱搞)
http://poj.org/problem?id=1989 题意:求一个序列的最短非子序列长度l,即长度小于l的所有数的排列都是原序列的子序列(不一定要连续的),求l得最小值. 分析: 我们从左到右 ...
- poj-1989 The Cow Lineup
The Cow Lineup Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5587 Accepted: 3311 Descri ...
- OJ题目分类
POJ题目分类 | POJ题目分类 | HDU题目分类 | ZOJ题目分类 | SOJ题目分类 | HOJ题目分类 | FOJ题目分类 | 模拟题: POJ1006 POJ1008 POJ1013 P ...
随机推荐
- Catalyst揭秘 Day3 sqlParser解析
Catalyst揭秘 Day3 sqlParser解析 今天我们会进入catalyst引擎的第一个模块sqlparser,它是catalyst的前置模块. 树形结构 从昨天的介绍我们可以看到sqlPa ...
- Django文档——Model字段选项(Field Options)
建立一个简易Model class Person(models.Model): GENDER_CHOICES=( (1,'Male'), (2,'Female'), ) name=models.Cha ...
- IIs上MP4、及SVG格式加载失败解决方式
部署项目是遇到网页播放mp4文件时候,MP4文件不能加载的问题.那是因为IIS上MIME类型中没有添加MP4的格式,添加一下即可. 解决方案: 1.在IIS上选中你的网站,然后点击右边的MIME类型, ...
- The Black Hole of Numbers (strtoint+inttostr+sort)
For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in ...
- 1065. A+B and C (64bit)
#include<stdio.h> #include <math.h> int main() { long long a,b,c,sum; int n,i; while(sca ...
- install ruby and ruby gem
sudo apt-get install ruby #find an folder and: git clone https://github.com/rubygems/rubygems.git cd ...
- python学习笔记6(字典)
映射:键值对的关系,键(key)映射值(value) 字典是Python唯一的映射类型 >>> phonebook = {'} >>> phonebook {'} ...
- Csharp volatile 关键字
volatile 关键字指示一个字段可以由多个同时执行的线程修改.声明为 volatile 的字段不受编译器优化(假定由单个线程访问)的限制.这样可以确保该字段在任何时间呈现的都是最新的值. vola ...
- 贪心算法——将正整数变为1
题目链接http://toutiao.com/a6320936270101528833/ 为避免链接失效,再粘贴一下题目内容: 给你一个数n,有3种操作: 1.这个数加1 2.这个数减1 3.如果这个 ...
- Linux下使用GDB调试程序
问题描述: Linux下使用GDB调试程序 问题解决: (1)生成调试文件 注: 使用命令 gdb IOStream.c -o IOStre ...