CodeForces 738D Sea Battle
抽屉原理。
先统计最多有$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的更多相关文章
- Codeforces 738D. Sea Battle 模拟
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard inp ...
- Codeforces 729D Sea Battle(简单思维题)
http://codeforces.com/contest/738/problem/D https://www.cnblogs.com/flipped/p/6086615.html 原 题意:海战 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【42.86%】【Codeforces Round #380D】Sea Battle
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Sea Battle
Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
随机推荐
- 「模板」 01 Trie实现平衡树功能
不想多说什么了.费空间,也不算太快,唯一的好处就是好写吧. #include <cstdio> #include <cstring> const int MAXN=100010 ...
- PowerDesigner16 用例图
用例图主要用来描述角色以及角色与用例之间的连接关系.说明的是谁要使用系统,以及他们使用该系统可以做些什么.一个用例图包含了多个模型元素,如系统.参与者和用例,并且显示这些元素之间的各种关系,如泛化.关 ...
- 【CodeForces】601 D. Acyclic Organic Compounds
[题目]D. Acyclic Organic Compounds [题意]给定一棵带点权树,每个点有一个字符,定义一个结点的字符串数为往下延伸能得到的不重复字符串数,求min(点权+字符串数),n&l ...
- html+js实现的触屏版贪吃蛇
查看线上demo(服务器经常断开,推荐下载源码本地打开): http://47.93.103.19:8044/client/ ; 使用手机打开或者chrome浏览器的手机模式打开 源码地址 :http ...
- 小程序_RSA加密功能
这是开发的第三个小程序,基于一个物流系统,简化功能开发下单流程.登录的时候,系统是使用RSA进行加解密的. 流程:第一个接口获取到后端传过来的密匙共钥(publicKey),通过公钥使用RSA加密密码 ...
- js_开发小技巧记录(一)
(一) 生成从minNum到maxNum的随机数 <!DOCTYPE html> <html> <head> <meta charset="UTF- ...
- Linux汇编教程03:大小比较操作
我们在上一讲中,简单了解了汇编程序大概的样子.接下来我们来了解一下,汇编程序的大小比较操作.所以我们以编写寻找一堆数中的最大值作为学习的载体. 在编写程序之前,先要分析我们的目的,在得出解决方案. 目 ...
- python基础===【字符串】所有相关操作
#字符串的相关操作 #基本操作 #+ 字符串连接操作 str1 = '来是come走是go' str2 = '点头yes摇头no' result = str1 + str2 print(result) ...
- HDU 5117 Fluorescent
题目链接:HDU-5117 题意为有n盏灯,m个开关,每个开关控制着\( k_{i} \)灯.X为最后亮着的灯的个数,要求出\( E(X^{3} ) * 2^{M} mod (10^9 + 7) \) ...
- node.js3
第一部分:express(MVC) 1.下载express npm install express --save 2.引入express require('express') 中间件 body-par ...