BZOJ4421 : [Cerc2015] Digit Division
如果两个相邻的串可行,那么它们合并后一定可行,所以求出所有可行的串的个数$t$,则$ans=2^{t-1}$。
注意特判整个串不可行的情况,这个时候答案为0。
#include<cstdio>
int n,m,i,t,ans;char a[300010];
int main(){
for(scanf("%d%d%s",&n,&m,a);i<n;i++){
t=(t*10+a[i]-'0')%m;
if(!t)if(!ans)ans=1;else ans=ans*2%1000000007;
}
return printf("%d",t?0:ans),0;
}
BZOJ4421 : [Cerc2015] Digit Division的更多相关文章
- 【BZOJ4421】[Cerc2015] Digit Division 动态规划
[BZOJ4421][Cerc2015] Digit Division Description 给出一个数字串,现将其分成一个或多个子串,要求分出来的每个子串能Mod M等于0. 将方案数(mod 1 ...
- BZOJ 4421: [Cerc2015] Digit Division
4421: [Cerc2015] Digit Division Time Limit: 1 Sec Memory Limit: 512 MBSubmit: 348 Solved: 202[Subm ...
- BZOJ 4421: [Cerc2015] Digit Division 排列组合
4421: [Cerc2015] Digit Division 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4421 Descripti ...
- [CERC2015]Digit Division
题目描述 We are given a sequence of n decimal digits. The sequence needs to be partitioned into one or m ...
- BZOJ 4421: [Cerc2015] Digit Division(思路)
传送门 解题思路 差点写树套树...可以发现如果几个数都能被\(m\)整除,那么这几个数拼起来也能被\(m\)整除.同理,如果一个数不能被\(m\)整除,那么它无论如何拆,都无法拆成若干个可以被\(m ...
- UVALive 7327 Digit Division (模拟)
Digit Division 题目链接: http://acm.hust.edu.cn/vjudge/contest/127407#problem/D Description We are given ...
- Digit Division
Digit Division Time limit: 1 s Memory limit: 512 MiB We are given a sequence of n decimal digits. Th ...
- Digit Division(排列组合+思维)(Gym 101480D )
题目链接:Central Europe Regional Contest 2015 Zagreb, November 13-15, 2015 D.Digit Division(排列组合+思维) 题解: ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
随机推荐
- NYOJ之素数求和问题
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsoAAAKCCAIAAABH/2gWAAAgAElEQVR4nO3dPVLjStsG4G8T5CyEdF
- 第一课 移动端&响应式
一.调试工具介绍(Chrome Emulation) 1.Device(设备相关) 自定义尺寸.Network(网络模拟).UseAgent(浏览器信息).缩放 2.Media(媒体) 3.Netwo ...
- 19.状态者模式(State Pattern)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- .net学习之委托和事件
1.什么是委托通俗的说:委托就是一个能够存储符合某种格式(方法签名)的方法的指针的容器上传图片: 2.委托语法准备一个方法:string Hello(string userName){} string ...
- Pyqt QComboBox 省市区县联动效果
在Qt中, QComboBox方法窗口组件允许用户从列表清单中选择,在web中就是select标签,下拉选项. 省市区县的联动就是currentIndexChanged 获取当前的Index,通过这个 ...
- 一个通过网络转换Ico到Png图片的小小程序(Ico2Png)
做软件界面需要用到ico文件, 结果皮肤库不支持ico格式的图标, 所以就想到了把ico转换成png. 网上ico转png的软件貌似并不多, 反倒是png转ico很大一片~~~~~~~~~ 要转换ic ...
- c++ 子类调用父类构造方法 调用父类方法 类声明与实现分离
Person.h #pragma once #include "stdafx.h" #include<iostream> class Person { private: ...
- go sample - mongodb
简单的mongodb 操作 package mainimport ( "fmt" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2 ...
- NS2中修改载波侦听范围和传输范围
修改这两个值是在tcl中进行的,加上 Phy/WirelessPhy set CSThresh_ 1.559e-11 ;#550m Phy/WirelessPhy set RXThresh_ 3.65 ...
- 等号赋值与memcpy的效率问题
转自:http://www.aiuxian.com/article/p-1309055.html 偶尔看到一个说法,说,小内存的拷贝,使用等号直接赋值比memcpy快得多.结合自己搜集到的资料,整理成 ...