CodeForces 716A Crazy Computer
题目链接:http://codeforces.com/problemset/problem/716/A
题目大意:
输入 n c, 第二行 n 个整数,c表示时间间隔 秒。
每个整数代表是第几秒。如果本次和下一秒间隔>c 则之前的计数次数清0,否则每次输入一个数,计数++;
问最后剩几个数。
举例:
input:
6 5
1 3 8 14 19 20
output:
3
解析:
1 3 8 此时剩 3 个数,因为每次输入距离下次输入时间间隔都<5。下一次是 14 距离上一次 间隔为14-8>5 ,计数清0。
下一次 19-14<5 保留,下一次 20-19<5 保留,故此时剩下 14 19 20 。所有输出 3.
解题思路:
先输入一个数,然后for剩下的数,如果下一个数与前一个是查大于 c 则cut=0,否则cut++;最后输出 cut+1.为什么+1 读者自己思考,可参考举例解析。
AC Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,c;
while(scanf("%d%d",&n,&c)!=EOF)
{
int i;
int x,x1,cut=;
scanf("%d",&x);
for(i=; i<n; i++)
{
scanf("%d",&x1);
if((x1-x)>c)
cut=;
else cut++;
x=x1;
}
printf("%d\n",cut+);
}
return ;
}
CodeForces 716A Crazy Computer的更多相关文章
- Codeforces 716A Crazy Computer 【模拟】 (Codeforces Round #372 (Div. 2))
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word
Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...
- Crazy Computer
ZS the Coder is coding on a crazy computer. If you don't type in a word for a cconsecutive seconds, ...
- Codeforces 498A Crazy Town
C. Crazy Town time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces 499C:Crazy Town(计算几何)
题目链接 给出点A(x1,y1),B(x2,y2),和n条直线(ai,bi,ci,aix + biy + ci = 0),求A到B穿过多少条直线 枚举每条直线判断A.B是否在该直线两侧即可 #incl ...
- CF716A Crazy Computer 题解
Content 有一个电脑,如果过了 \(c\) 秒之后还没有任何打字符的操作,就把屏幕上面所有的字符清空.现在,给定 \(n\) 次打字符的时间 \(t_1,t_2,...,t_n\),求最后屏幕剩 ...
- Codeforces水题集合[14/未完待续]
Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...
- Codeforces Round #370 - #379 (Div. 2)
题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi ...
- Codeforces Round #372 (Div. 2) A
Description ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecut ...
随机推荐
- C++_STL
容器概念讲解 vector deque
- ActiveMQ(七)_伪集群和主从高可用使用
一.本文目的 介绍如何在同一台虚拟机上搭建高可用的Activemq服务,集群数量包含3个Activemq,当Activemq可用数>=2时,整个集群可用. 本 ...
- 【BZOJ 1031】【JSOI 2007】字符加密Cipher
后缀数组模板题,看了一天的后缀数组啊,我怎么这么弱TwT #include<cstdio> #include<cstring> #include<algorithm> ...
- JavaScript的DOM操作-非重点部分
1.DOM的基本概念 DOM是文档对象模型,这种模型为树模型:文档是指标签文档(HTML文档),对象是指文档中每个元素:模型是指抽象划的东西. 2.Windows对象操作 一.属性和方法 属性(值或者 ...
- 【CodeForces 615E】Hexagons
找规律. #include <cstdio> #include <iostream> #include <algorithm> #include <cstri ...
- Code::Blocks的魅力
Code::Blocks是C/C++集成开发环境,就像Dev C++.Visual Studio. 一.码代码时的技巧 按住Ctrl滚动鼠标滚轮,改变字体大小. Ctrl+D可复制当前行或选中块. C ...
- 解决bind错误 bind: Address already in use
关于bind错误的处理: bind: Address already in use 原因: 操作系统没有立即释放端口 解决一: 等待一段时间运行网络程序即可 解决二:通过setsockopt进行设置, ...
- bzoj 1257
商最多有sqrt(n)个. #include<iostream> #include<cstdio> #include<cstring> #include<al ...
- eclipse各版本代号
从2006年起,Eclipse基金会每年都会安排同步发布(simultaneous release).同步发布主要在6月进行,并且会在接下来的9月及2月释放出SR1及SR2版本.如下图所示的版本历史: ...
- ecshop /api/client/api.php、/api/client/includes/lib_api.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 ECShop存在一个盲注漏洞,问题存在于/api/client/api. ...