CF1036C Classy Numbers dfs+二分】的更多相关文章

Classy Numbers time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Let's call some positive integer classy if its decimal representation contains no more than 33 non-zero digits. For example,…
题目大意:多个询问,每个询问问$[l,r](1\leqslant l\leqslant r\leqslant10^{18})$内有多少个数满足非零数位小于等于$3$. 题解:数位$DP$,$f_{i,j}$表示在第$i$位,有$j$个数位不是$0$的方案数 卡点:无 C++ Code: #include <cstdio> #include <cstring> int Tim, num[20]; long long M[5][20]; long long run(int x, int…
Description In the ``Four Color Map Theorem" was proven with the assistance of a computer. This theorem states that every map can be colored using only four colors, in such a way that no region is colored using the same color as a neighbor region. He…
C. Classy Numbers 题目链接:https://codeforces.com/contest/1036/problem/C 题意: 给出n个询问,每个询问给出Li,Ri,问在这个闭区间中有多少个数满足,除开0之外,最多只有4个数字. 题解: 由于题目给出的数满足前缀性质,所以我们可以直接求[1,r]这个区间中有多少个数满足就好了. 具体做法就是从高位往低位来看,然后如果当前数组不为0,假设为p,那么当前数组对答案的贡献就比较好计算了,假设后面的数有x位,目前已经有k个数字了. 那么…
655. 输出二叉树 在一个 m*n 的二维字符串数组中输出二叉树,并遵守以下规则: 行数 m 应当等于给定二叉树的高度. 列数 n 应当总是奇数. 根节点的值(以字符串格式给出)应当放在可放置的第一行正中间.根节点所在的行与列会将剩余空间划分为两部分(左下部分和右下部分).你应该将左子树输出在左下部分,右子树输出在右下部分.左下和右下部分应当有相同的大小.即使一个子树为空而另一个非空,你不需要为空的子树输出任何东西,但仍需要为另一个子树留出足够的空间.然而,如果两个子树都为空则不需要为它们留出…
<题目链接> 题目大意: 对于那些各个位数上的非0数小于等于3的数,我们称为 classy number ,现在给你一个闭区间 [L,R]  (1≤L≤R≤1018).,问你这个区间内有多少个classy number 数. 解题分析: 对于这种对数的数位有要求的题目,可以往搜索,dp上想一想,本题可用搜索做.先用搜索将所有符合条件的数放入vector ,然后排序,再用二分函数得到 L,R的坐标,再相减,即可得到 [L,R]区间中满足条件的数的个数. #include <bits/std…
时间限制:1000MS  内存限制:65535K提交次数:0 通过次数:0 题型: 编程题   语言: G++;GCC Description Global warming is a big problem, isn't it? It is reported that the ice of Antarctica is melting. It results that oceans are glowing and more and more places are flooded. Now the…
A. Tavas and Nafas time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operati…
链接 ztrloveslucky numbers 题意 定义幸运数为:只存在4和7且4和7数量相等的数,给出n,求比>=n的最小幸运数 做法 暴力搜出所有长度从2-18的幸运数,因为最多9个4,9个7,再大的话好像数组存不下只能特判了,然后二分找出比这个数大的那个数就行了 代码 #include<bits/stdc++.h> using namespace std; #define LL long long LL n[1100000]; int s4, s7, len, t; void…
get了很多新技能 当时想到了用dfs,但是排序用的是限制时间排序,一直没搞出来. 正解: 二分用时,dfs判断,为了顺利进行做题,需要按照做题开始时间排序 还可以用dp 题意: 作为史上最强的刷子之一,zhx常常参与各种比赛. 有一天,zhx去虐一场比赛.他觉得题太简单了. 这场比赛有n道题.他一眼就已经计算出他做第i道题要花ti的时间,做完后可以得到vi分. 因为他太强了,所以他被管理员盯上了.如果他在第li个单位时间前做完了第i道题,那么管理员就会认为他在作弊,然后把他的号封了. zhx不…