找规律/数位DP HDOJ 4722 Good Numbers】的更多相关文章

题目传送门 /* 找规律/数位DP:我做的时候差一点做出来了,只是不知道最后的 is_one () http://www.cnblogs.com/crazyapple/p/3315436.html 数位DP:http://blog.csdn.net/libin56842/article/details/11580497 */ #include <cstdio> #include <iostream> #include <algorithm> #include <c…
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant very much loves sums on intervals. This time he has a pair of integers l and r (l ≤ r…
题目 https://nanti.jisuanke.com/t/17118 题意 有n个点0,1,2...n-1,对于一个点对(i,j)满足i<j,那么连一条边,边权为i xor j,求0到n-1的最大流,结果取模,n<=1e18 分析 可以写个最大流对数据找规律,但没找出来…… 然后只能取分析了,首先最大流等价于最小割 明确一定,0->n-1这个要先割掉 然后我们贪心,希望有一些点割掉与0相连的边,一些点割掉与n-1相连的边 我们去观察每个点与0相连和与n-1相连的两条边权值,容易发现…
老年选手需要多写一些思维题qwq. 通过打表很容易发现对于(i,j),值为(i-1)^(j-1)+1,然后本题就没了qwq. 矩阵差分还是很容易想到的,容斥成四个矩阵. 然后看到异或很容易想到三件事:数位DP.字典树.线性基.很容易发现后两种与本题不符,就是数位DP了,从高位到低位DP,f[i][0/1][0/1][0/1]表示到第i位,当前的x.y.x^y是否达到上界,然后直接暴力枚举当前位即可.因为q<=1e4怕memset多了出事,我用了滚动数组qwq. #include<bits/st…
题意:给定x.y.为[x,y]之间有多少个数的偶数位和减去奇数位和等于一. 个位是第一位. 样例: 10=1-0=1 所以10是这种数 思路:数位dp[i][sum][ok] i位和为sum 是否含有前导0. 然后就是由于有负数 所以依据范围把0设置为100 然后最后和等于101则为所求的数. 代码: #include"cstdlib" #include"cstdio" #include"cstring" #include"cmath&…
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<queue> using namespace std; #define ll long long #define maxn 100050 int ok(ll n){ *;i<=n;i++){ ll sum = ,tmp = i; while(tmp){ sum += tmp%; tm…
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the…
题目链接 题意:定义"beautiful number"为一个数n能整除所有数位上非0的数字 分析:即n是数位所有数字的最小公倍数的倍数.LCM(1到9)=2520.n满足是2520的约数的倍数.dp[len][val][lcm]一维为数的位数,一维为%2520的值(保存原数不可能,也没必要,2520是可行的最小公倍数最大的一个),一维为当前数位的lcm,判断满足的条件是val%lcm==0.这题离散化2520的约数,否则空间开不下. #include <bits/stdc++.…
$dp[x][p][pp]$表示第x位,当前已有数字mod 2520(1~9数字的lcm)为p,当前各位数字的lcm为pp 观察到数组太大,考虑压缩,第三维lcm最多只有9个数字,打表发现最多只有48个状态,压掉第三维即可 打表用一个状压然后set维护(广搜也可以)即可 有一个坑点:题目里似乎没有说关于0的事情(即数字里出现0)但是有人在CF上打这个比赛的时候问了出题人,碰到0不要管即可!!! 打表代码: set<int>s; inline void Make(int x){ ; ;i<…
剑指 Offer 44. 数字序列中某一位的数字 Offer_44 题目描述 题解分析 java代码 package com.walegarrett.offer; /** * @Author WaleGarrett * @Date 2021/2/8 10:01 */ /** * 题目描述: * 数字以0123456789101112131415-的格式序列化到一个字符序列中.在这个序列中,第5位(从下标0开始计数)是5,第13位是1,第19位是4,等等. * 请写一个函数,求任意第n位对应的数字…