hdu 6020 MG loves apple 恶心模拟
题目链接:点击传送
MG loves apple
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
A valid number does not contain a leading zero, and these apples have just made a valid N digit number.
MG has the right to take away K apples in the sequence, he wonders if there exists a solution: After exactly taking away K apples, the valid N−K digit number of remaining apples mod 3 is zero.
MG thought it very easy and he had himself disdained to take the job. As a bystander, could you please help settle the problem and calculate the answer?
And as for each case, there are 2 integer N(1<=N<=100000),K(0<=K<N) in the first line which indicate apple-number, and the number of apple you should take away.
MG also promises the sum of N will not exceed 1000000。
Then there are N integers X in the next line, the i-th integer means the i-th gold’s value(0<=X<=9).
If the solution exists, print”yes”,else print “no”.(Excluding quotation marks)
5 2
11230
4 2
1000
no
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
#define bug(x) cout<<"bug"<<x<<endl;
const int N=1e5+,M=1e6+,inf=;
const ll INF=1e18+,mod=;
int num[N][];
int check0(int a,int x,int y,int z)
{
if(a<||x<||y<||z<)return ;
int ans=;
if(x>=&&y>=&&z>=)
{
int xx=x,yy=y,zz=z;
xx-=;yy-=;zz-=;
int l=(xx/+yy/);
zz-=min(zz/,l)*;
if(zz<=a)ans=;
}
if(x>=&&y>=&&z>=)
{
int xx=x,yy=y,zz=z;
xx-=;yy-=;zz-=;
int l=(xx/+yy/);
zz-=min(zz/,l)*;
if(zz<=a)ans=;
}
int xx=x,yy=y,zz=z;
int l=(xx/+yy/);
zz-=min(zz/,l)*;
if(zz<=a)ans=;
return ans;
}
int check1(int a,int x,int y,int z)
{
return max(check0(a,x-,y,z-),check0(a,x,y-,z-));
}
int check2(int a,int x,int y,int z)
{
return max(check0(a,x,y-,z-),check0(a,x-,y,z-));
}
char a[N];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(num,,sizeof(num));
int n,K;
scanf("%d%d",&n,&K);
scanf("%s",a+);
if(K==n-)
{
int mmp=;
for(int i=;i<=n;i++)
if(a[i]%==)mmp=;
if(mmp)printf("yes\n");
else printf("no\n");
continue;
}
int sum=;
for(int i=;i<=n;i++)
sum+=a[i]-'';
int x=sum%;
for(int i=n;i>=;i--)
{
int x=(a[i]-'')%;
num[i][]=num[i+][];
num[i][]=num[i+][];
num[i][]=num[i+][];
num[i][x]++;
}
int ans=;
/// 枚举以i+1为起点的,去掉前i个,后面的需要去掉k-i个,进行check()
for(int i=;i<=K;i++)
{
if(a[i+]=='')continue;
if(x==)ans=max(ans,check1(num[i+][],num[i+][],num[i+][],K-i));
else if(x==)ans=max(ans,check2(num[i+][],num[i+][],num[i+][],K-i));
else ans=max(ans,check0(num[i+][],num[i+][],num[i+][],K-i));
x-=a[i+]-'';
x=(x%+)%;
}
if(ans)
printf("yes\n");
else
printf("no\n");
}
return ;
}
hdu 6020 MG loves apple 恶心模拟的更多相关文章
- 【HDU 6020】 MG loves apple (乱搞?)
MG loves apple Accepts: 20 Submissions: 693 Time Limit: 3000/1500 MS (Java/Others) Memory Limit: ...
- hdu 6021 MG loves string
MG loves string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others ...
- hdu 6021 MG loves string (一道容斥原理神题)(转)
MG loves string Accepts: 30 Submissions: 67 Time Limit: 2000/1000 MS (Java/Others) Memory ...
- HDU 5805 NanoApe Loves Sequence (模拟)
NanoApe Loves Sequence 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5805 Description NanoApe, the ...
- HDU 5806 NanoApe Loves Sequence Ⅱ (模拟)
NanoApe Loves Sequence Ⅱ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5806 Description NanoApe, t ...
- 【BestCoder Round #93 1002】MG loves apple
[题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=6020 [题意] 给你一个长度为n的数字,然后让你删掉k个数字,问你有没有删数方案使得剩下的N-K个 ...
- HDU 5268 ZYB loves Score (简单模拟,水)
题意:计算Bestcoder四题的得分. 思路:直接模拟,4项分数直接计算后输出.注意不要低于百分之40的分. //#include <bits/stdc++.h> #include &l ...
- ●HDU 6021 MG loves string
题链: http://acm.hdu.edu.cn/showproblem.php?pid=6021 题解: 题意:对于一个长度为 N的由小写英文字母构成的随机字符串,当它进行一次变换,所有字符 i ...
- HDU 5995 Kblack loves flag (模拟)
题目链接 Problem Description Kblack loves flags, so he has infinite flags in his pocket. One day, Kblack ...
随机推荐
- Spark性能优化(二)
资源调优 调优概述 在开发完Spark作业之后,就该为作业配置合适的资源了.Spark的资源参数,基本都可以在spark-submit命令中作为参数设置.很多Spark初学者,通常不知道该设置哪些必要 ...
- [py][mx]django注册-邮件激活
人生,学习,就是一段旅途, 说是放弃,其实是自信心作祟. 因为不同时间段状态,譬如晚上和早上刚来状态不一样.做相同事情容器失去自信而放弃. 坚持可以打破这个魔咒 还有就是有些问题得分割, 不要让压死牛 ...
- WebService之Axis2 (3):使用services.xml文件发布WebService
用Axis2实现Web Service,虽然可以将POJO类放在axis2\WEB-INF\pojo目录中直接发布成Web Service,这样做不需要进行任何配置,但这些POJO类不能在任何包中.这 ...
- 【C语言】指向一维数组元素的指针
本文目录 一.用指针指向一维数组的元素 二.用指针遍历数组元素 三.指针与数组的总结 四.数组.指针与函数参数 前面我们已经学习了指针,如果指针存储了某个变量的地址,我们就可以说指针指向这个变量.数组 ...
- cocos2dx-环境搭建和创建项目(mac用)
学习一门语言最快的方法就是制作一个简单的项目. 而要制作一个项目必须先搭好环境,即使花上2小时去熟悉环境创建也不算浪费.由于之后的项目会用到cocos2d-x 3.0,这里以3.0为例子(不同的版本写 ...
- VS添加节点
很喜欢添加节点来减少代码的长度,方便阅读:VS快捷键和相关设置
- linux常用命令:find 命令之 exec
find是我们很常用的一个Linux命令,但是我们一般查找出来的并不仅仅是看看而已,还会有进一步的操作,这个时候exec的作用就显现出来了. exec解释: -exec 参数后面跟的是command ...
- eclipse svn插件 设置自动加锁相关
eclipse svn插件 设置自动加锁相关 Subclipse 1.10.9 发布,改进说明:SVNKit 1.8.8Exception proof repository sorter. (1616 ...
- 配置mysql主从数据库
来源地址:https://www.cnblogs.com/alvin_xp/p/4162249.html Mysql主从配置,实现读写分离 大型网站为了软解大量的并发访问,除了在网站实现分布式负载均衡 ...
- mysql 触发器 trigger用法 two (稍微复杂的)
触发器(trigger):监视某种情况,并触发某种操作. 触发器创建语法四要素:1.监视地点(table) 2.监视事件(insert/update/delete) 3.触发时间(after/befo ...