BZOJ 4421: [Cerc2015] Digit Division
4421: [Cerc2015] Digit Division
Time Limit: 1 Sec Memory Limit: 512 MB
Submit: 348 Solved: 202
[Submit][Status][Discuss]
Description
Input
Output
如题
Sample Input
1246
Sample Output
HINT
Source
只需要求出所有能使得前缀数字串在mod意义下等于0的位置,设为$t$,则从这些位置任意切开,得到的串均满足要求。每个位置有两种选项(切或不切)答案是$2^{t}$。
#include <cstdio> const int mod = 1e9 + ; int n, m, t;
char s[]; inline int pow(long long a, int b)
{
long long r = ; while (b)
{
if (b & )
{
r *= a; if (r >= mod)
r %= mod;
} b >>= ;
a = a * a; if (a >= mod)
a %= mod;
} return r;
} signed main(void)
{
scanf("%d%d%s", &n, &m, s); int sum = ; for (char *c = s; *c; ++c)
{
sum = sum * + *c - ''; if (sum >= m)
sum %= m; if (sum == )
++t;
} printf("%d\n", sum ? : pow(, t - ));
}
@Author: YouSiki
BZOJ 4421: [Cerc2015] Digit Division的更多相关文章
- BZOJ 4421: [Cerc2015] Digit Division 排列组合
4421: [Cerc2015] Digit Division 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4421 Descripti ...
- BZOJ 4421: [Cerc2015] Digit Division(思路)
传送门 解题思路 差点写树套树...可以发现如果几个数都能被\(m\)整除,那么这几个数拼起来也能被\(m\)整除.同理,如果一个数不能被\(m\)整除,那么它无论如何拆,都无法拆成若干个可以被\(m ...
- 【BZOJ4421】[Cerc2015] Digit Division 动态规划
[BZOJ4421][Cerc2015] Digit Division Description 给出一个数字串,现将其分成一个或多个子串,要求分出来的每个子串能Mod M等于0. 将方案数(mod 1 ...
- BZOJ4421 : [Cerc2015] Digit Division
如果两个相邻的串可行,那么它们合并后一定可行,所以求出所有可行的串的个数$t$,则$ans=2^{t-1}$. 注意特判整个串不可行的情况,这个时候答案为0. #include<cstdio&g ...
- [CERC2015]Digit Division
题目描述 We are given a sequence of n decimal digits. The sequence needs to be partitioned into one or 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 4436][Cerc2015]Kernel Knights
[Cerc2015]Kernel Knights Time Limit: 2 Sec Memory Limit: 512 MBSubmit: 5 Solved: 4[Submit][Status][D ...
随机推荐
- 树莓派操控SG90舵机
目录 舵机接线 PWM介绍 使用PWM控制舵机 这里使用树莓派来操作sg90的舵机.先看一下这个舵机的样子: 这就是传说中的SG90舵机啦,转角是0-180. SG90舵机接线: SG90舵机有三条线 ...
- 32bit 天堂2 windows 2000 server架设教程
服务器的软件要求: Microsoft Windows 2000 Server or advanced Server license 100 Microsoft SQL Server 2000 Ent ...
- mongoose和mongodb的几篇文章 (ObjectId,ref)
http://mongoosejs.com/docs/populate.html http://stackoverflow.com/questions/6578178/node-js-mongoose ...
- sync命令详解
转:https://blog.csdn.net/everything1209/article/details/50423679 1.谁和谁同步? 2.为什么要同步?复制移动的过程不是同步的吗,都发生了 ...
- Ambiguous mapping. Cannot map 'labelInfoController' method
使用springboot项目中,启动时出现Ambiguous mapping. Cannot map 'labelInfoController' method , 原因是,@RequestMappin ...
- [BUAA OO]第一次博客作业
第一次作业 第一次进行面向对象的编程,不论是针对数据设计类还是对方法进行合适的归于不同类中,都不是很熟悉.所写出来的程序还是面向过程+有函数的类(虽然现在很大程度上感觉起来也是这样).索性作业难度并不 ...
- 《校友聊—方便使用之NABCD》
<校友聊—方便使用之NABCD> 方便使用特点的分析与总结: N:由于一些软件的人机交互性很差,人性化性能低,使用不方便,故,鉴于此需求:A:用户可根据系统界面的友好提示一步步进行:B:提 ...
- model类的构造部分属性的对象 产生的json
在 action方法里, 产生一个对象,可能会是默认的全属性对象,那么在输出的 json就又所有 都出现了. 只是其他的属性全部是 null 那么 在 json里面配上 <!-- json 不产 ...
- Codeforces Round #105 (Div. 2) D. Bag of mice 概率dp
题目链接: http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test2 secondsmemo ...
- HDU 1015 Jury Compromise 01背包
题目链接: http://poj.org/problem?id=1015 Jury Compromise Time Limit: 1000MSMemory Limit: 65536K 问题描述 In ...