抽屉原理。

先统计最多有$sum$个船可以放,假设打了$sum-a$枪都没打中$a$个船中的任意一个,那么再打$1$枪必中。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar();
x = ;
while(!isdigit(c)) c = getchar();
while(isdigit(c))
{
x = x * + c - '';
c = getchar();
}
} int n,a,b,k;
char s[];
struct X
{
int L;
int cnt;
}t[];
int sz,cnt;
int sum; int main()
{
cin>>n>>a>>b>>k;
cin>>s; for(int i=;s[i];)
{
if(s[i]=='')
{
int j;
for(j=i;s[j];j++)
{
if(s[j]=='') continue;
break;
}
j--; t[sz].L=i;
t[sz].cnt=j-i+;
sz++;
i=j+;
}
else i++;
} for(int i=;i<sz;i++) sum=sum+t[i].cnt/b; int now=; printf("%d\n",sum-a+); for(int i=;i<sz;i++)
{
for(int j=;j<=t[i].cnt/b;j++)
{
printf("%d ",t[i].L+j*b);
now++;
if(now==sum-a+) break;
}
if(now==sum-a+) break;
} return ;
}

CodeForces 738D Sea Battle的更多相关文章

  1. Codeforces 738D. Sea Battle 模拟

    D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...

  2. Codeforces 729D Sea Battle(简单思维题)

    http://codeforces.com/contest/738/problem/D https://www.cnblogs.com/flipped/p/6086615.html   原 题意:海战 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【42.86%】【Codeforces Round #380D】Sea Battle

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. Codeforces #380 div2 D(729D) Sea Battle

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) D. Sea Battle 模拟

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  7. Codeforces Round #380 (Div. 2)D. Sea Battle

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  8. Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题

    Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the ...

  9. Sea Battle

    Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

随机推荐

  1. redis初试Not all 16384 slots are covered by nodes

    按照这里的步骤玩redis集群,http://www.redis.cn/topics/cluster-tutorial.html ./src/redis-trib.rb create --replic ...

  2. C# 生成系统唯一号

    生成唯一号:思路,根据yymmddhhmmss+自增长号+唯一服务器号( SystemNo)生成唯一码,总长度19,例如:1509281204550000101. public class Uniqu ...

  3. HihoCoder 重复旋律

    あの旋律を何度も繰り返しでも.あの日見た光景を再現できない 无论将那段旋律重复多少次,也无法重现那一日我们看到的景象 もし切ないならば.時をまきもどしてみるかい? 若是感到惆怅的话,要试着让时光倒流吗 ...

  4. 深入浅出MyBatis:JDBC和MyBatis介绍

    JDBC相关概念 Java程序都是通过JDBC连接数据库的,通过SQL对数据库编程,JDBC是由SUN公司提出的一些列规范,只定义了接口规范,具体实现由各个数据库厂商去实现,它是一种典型的桥接模式. ...

  5. aspnet_regiis.exe -i 执行报错

    IIS刚部署时出现问题 处理程序“svc-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler” 按照网上的步骤,使用管理员打开CMD 开始->所有程 ...

  6. 关于win7局域网共享的相关设置

    模式1> 被访问方相关设置步骤: (1)被共享方的电脑开通来宾用户 (2)被共享方的电脑的本地安全策略需要设置成 "仅来宾" (3)被共享方的电脑高级共享设置中 " ...

  7. html meta标签作用

    1.概要 标签提供关于HTML文档的元数据.元数据不会显示在页面上,但是对于机器是可读的.它可用于浏览器(如何显示内容或重新加载页面),搜索引擎(关键词),或其他web服务. 必要属性: conten ...

  8. 【Python学习笔记】多版本python使用pip安装第三方库

    不知道是不是有人跟我一样,一直Python2与Python3混着用,然而在cmd中默认的Python版本只有一种,使用 pip install xxx(第三方库名)  只会安装到默认版本上. 而如果需 ...

  9. python基础===8道基础知识题

    本文转自微信公众号: 2018-03-12 leoxin 菜鸟学Python 原文地址:http://mp.weixin.qq.com/s/JJSDv5YJOZ9e3hn28zWIsQ NO.1 Py ...

  10. c++ ui 库

    Dulib 比较流行的direct ui 界面框架 UIStone 据说金山词霸用着,查询资料甚少 DirectUI qq使用了据说,多学习学习吧 基于directUI的dulib不错 c盘没空间,运 ...