CF585F Digits of Number Pi】的更多相关文章

题目 把\(s\)串所有长度为\(\lfloor \frac{d}{2}\rfloor\)的子串插入一个ACAM中,之后数位dp就好了,状态是\(dp_{i,j,0/1}\)第\(i\)位,在ACAM上的节点\(j\),不卡/卡上界:正难则反一下,统计所有不能被表示即没有经过结束标记的路径即可 注意前导0的处理 代码 #include<bits/stdc++.h> #define re register #define LL long long const int mod=1e9+7; cha…
考虑用数位 \(DP\) 来统计数字串个数,用 \(SAM\) 来实现子串的匹配. 设状态 \(f(pos,cur,lenth,lim,flag)\),表示数位的位数,在 \(SAM\) 上的节点,匹配的长度,是否有最高位限制,是否已经满足要求. 在 \(dfs\) 转移时,若当前节点能接着匹配枚举到的字符,就直接转移,若不能,则在 \(Parent\) 树上向上跳,直到能接着匹配,转移过程中判断是否满足条件即可. \(code:\) #include<bits/stdc++.h> #defi…
题目大意: 给你一个数字串s,一个序列范围l和r,(l和r的数字位数为d)求l到r中有多少个数,满足它的长度为d/2的子串,能够在s中被匹配. 思路: 首先将s中每一个长度为d/2的子串插入后缀自动机. 然后数位DP. f[i][j]中第一维表示当前树与l和r的关系,包含四个状态,用二进制表示,每一位对应与l和r的不同关系. 第二维表示当前状态下每个结点匹配到的数的个数. 每一个数位的状态由上一个数位转移而来,我们用两个DP数组f和g滚动实现. 用o表示当前枚举的数字,用to表示数字所对应的第一…
题目如下: Given an array nums of integers, return how many of them contain an even number of digits. Example 1: Input: nums = [12,345,2,6,7896] Output: 2 Explanation: 12 contains 2 digits (even number of digits).  345 contains 3 digits (odd number of dig…
1.π (Pi; periphery/周长) March 14 marks Pi Day, the holiday commemorating the mathematical constant π (pi), written numerically as 3.141592+. Since mathematic notation is a language that uses symbols from a multitude of alphabets and typefaces, it seem…
Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the…
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.…
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Input: 38 Output: 2 Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2.   Since 2 has only one digit, return it. Follow up:Could you do…
4877 Non-Decreasing Digits A number is said to be made up ofnon-decreasing digitsif all the digits to theleftof any digit is lessthan or equal to that digit. For example, the four-digit number 1234 is composed of digits that arenon-decreasing. Some o…
题目链接 Description If we input a number formed by 4 digits and these digits are not all of one same value, then it obeys the following law. Let us operate the number in the following way: (1) Arrange the digits in the way from bigger to smaller, such t…