Digit Division】的更多相关文章

Digit Division 题目链接: http://acm.hust.edu.cn/vjudge/contest/127407#problem/D Description We are given a sequence of n decimal digits. The sequence needs to be partitioned into one or more contiguous subsequences such that each subsequence, when interp…
4421: [Cerc2015] Digit Division Time Limit: 1 Sec  Memory Limit: 512 MBSubmit: 348  Solved: 202[Submit][Status][Discuss] Description 给出一个数字串,现将其分成一个或多个子串,要求分出来的每个子串能Mod M等于0. 将方案数(mod 10^9+7)   Input 给出N,M,其中1<=N<=300 000,1<=M<=1000 000. 接下来一行…
4421: [Cerc2015] Digit Division 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4421 Description 给出一个数字串,现将其分成一个或多个子串,要求分出来的每个子串能Mod M等于0. 将方案数(mod 10^9+7) Input 给出N,M,其中1<=N<=300 000,1<=M<=1000 000. 接下来一行,一个数字串,长度为N. Output 如题 Sample In…
[BZOJ4421][Cerc2015] Digit Division Description 给出一个数字串,现将其分成一个或多个子串,要求分出来的每个子串能Mod M等于0. 将方案数(mod 10^9+7) Input 给出N,M,其中1<=N<=300 000,1<=M<=1000 000. 接下来一行,一个数字串,长度为N. Output 如题 Sample Input 4 2 1246 Sample Output 4 题解:如果一个前缀a%m==0,另一个长一点的前缀b…
Digit Division Time limit: 1 s Memory limit: 512 MiB We are given a sequence of n decimal digits. The sequence needs to be partitioned into one or more contiguous subsequences such that each subsequence, when interpreted as a decimal number, is divis…
题目链接:Central Europe Regional Contest 2015 Zagreb, November 13-15, 2015 D.Digit Division(排列组合+思维) 题解:如果这个数从划分的过程中第一.二道竖线前的能够整除m,那么第一道与第二道竖线之间的数也能够整除m. #include <bits/stdc++.h> using namespace std; typedef long long ll; char a[300005]; ll qpow(ll x,ll…
如果两个相邻的串可行,那么它们合并后一定可行,所以求出所有可行的串的个数$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…
题目描述 We are given a sequence of n decimal digits. The sequence needs to be partitioned into one or more contiguous subsequences such that each subsequence, when interpreted as a decimal number, is divisible by a given integer m. Find the number of di…
传送门 解题思路 差点写树套树...可以发现如果几个数都能被\(m\)整除,那么这几个数拼起来也能被\(m\)整除.同理,如果一个数不能被\(m\)整除,那么它无论如何拆,都无法拆成若干个可以被\(m\)整除的数.这样的话只需要看那些被\(m\)整除的前缀个数,然后选与不选直接\(2^cnt\)即可. 代码 #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #inc…
-------------------题目难度较难,但挺有营养的.慢慢补. A .ASCII Addition pro:用一定的形式表示1到9,让你计算加法. sol:模拟. solved by fzl; #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=b;i++) using namespace std; ; typedef long long ll; ] = { "xxxxxx...xx...xx...xx…