题目链接: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的更多相关文章

  1. 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 ...

  2. Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word

    Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...

  3. Crazy Computer

    ZS the Coder is coding on a crazy computer. If you don't type in a word for a cconsecutive seconds, ...

  4. Codeforces 498A Crazy Town

    C. Crazy Town time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. Codeforces 499C:Crazy Town(计算几何)

    题目链接 给出点A(x1,y1),B(x2,y2),和n条直线(ai,bi,ci,aix + biy + ci = 0),求A到B穿过多少条直线 枚举每条直线判断A.B是否在该直线两侧即可 #incl ...

  6. CF716A Crazy Computer 题解

    Content 有一个电脑,如果过了 \(c\) 秒之后还没有任何打字符的操作,就把屏幕上面所有的字符清空.现在,给定 \(n\) 次打字符的时间 \(t_1,t_2,...,t_n\),求最后屏幕剩 ...

  7. Codeforces水题集合[14/未完待续]

    Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...

  8. Codeforces Round #370 - #379 (Div. 2)

    题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi  ...

  9. 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 ...

随机推荐

  1. 如何调试js文件

    来源于:http://stackoverflow.com/questions/988363/how-can-i-debug-my-javascript-code http://stackoverflo ...

  2. HTML5基础知识(1)--上标和下标文本

    1.上标文本标签:<sup>/<sup> 2.下标文本标签:<sub></sub> 3.案例代码 <!doctype html> <h ...

  3. win7命令行 端口占用 查询进程号 杀进程

    打开CMD窗口 win+R–>cmd 根据端口号查找进程号 netstat -nao|grep 端口号 根据进程号得到进程名 tasklist |findstr 进程号 杀进程 taskkill ...

  4. VMWare虚拟机提供的桥接、nat和主机模式的区别

    虚拟机网络模式 无论是vmware,virtual box,virtual pc等虚拟机软件,一般来说,虚拟机有三种网络模式: 1.桥接 2.NAT 3.Host-Only 哪一种网络是适合自己的虚拟 ...

  5. Ubuntu 14.04 安装 JDK 8,ubuntu14.04

    第一步,下载Linux版JDK 可以通过访问Oracle官网下载,或者直接通过命令行下载. lxh@ubuntu:~$ wget -c http://download.oracle.com/otn-p ...

  6. HTML video 视频标签全属性详解

    HTML 5 video 视频标签全属性详解   现在如果要在页面中使用video标签,需要考虑三种情况,支持Ogg Theora或者VP8(如果这玩意儿没出事的话)的(Opera.Mozilla.C ...

  7. 使用redis作为session的存储方式

    (1)准备 A. 安装好redis https://github.com/MSOpenTech/redis  注意:下载release版 启动脚本如下: redis-server  redis.win ...

  8. 精通Web Analytics 2.0 (3) 第一章:网站分析的新奇世界

    精通Web Analytics 2.0 : 用户中心科学与在线统计艺术 第一章:Web Analytics 2.0的新奇世界 多年以来,我们很清楚的知道,网站分析能够真正的改革网络上业务的完成方式.那 ...

  9. break 的一个“高级用法”(转)

    转载:http://blog.csdn.net/lovelan1748/article/details/5321558 本小节不是很适于没有多少实际编程经历的初学者,所以初学者可以跳过,以后再回头阅读 ...

  10. 华硕笔记本之secure boot

    在ubuntu下安装cuda的时候,一直装不好,cuda-7.5.run已经装好了,但是编译cuda的例程时失败,提示cuda的库链接不上. 初步判断是secure boot的问题,因为在开启X的情况 ...