CF893B Beautiful Divisors 题解】的更多相关文章

Content 给定一个数 \(n\),求出 \(n\) 最大的可以表示成 \((2^k-1)\cdot2^{k-1}\) 形式的因数 \(x\). 数据范围:\(1\leqslant n\leqslant 10^5\). Solution 数据范围很小,所以我们先考虑将 \(10^5\) 以内的能够表示成 \((2^k-1)\cdot2^{k-1}\) 形式的数全部通过打表生成出来.而且打完以后,我们发现,事实上满足这个条件的数在 \(10^5\) 以内只有 \(8\) 个:\(1,6,28,…
893B Beautiful Divisors 思路: 打表 代码: #include <bits/stdc++.h> using namespace std; #define _for(i,a,b) for(int i=(a); i<(b); ++i) #define _rep(i,a,b) for(int i=(a); i<=(b); ++i) int a[8]={1,6,28,120,496,2016,8128,32640}; int main() { int n; scan…
B. Beautiful Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful…
题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful…
题目描述 定义 \(d(n)\) 为 \(n\) 的正因数的个数,比如 \(d(2) = 2, d(6) = 4\). 令 $ S_1(n) = \sum_{i=1}^n d(i) $ 给定 \(n\),求 \(S_1(n)\). 输入格式 第一行包含一个正整数 \(T\) (\(T \leq 10^5\)),表示数据组数. 接下来的 \(T\) 行,每行包含一个正整数 \(n\) (\(n < 2^{63}\)). 输出格式 对于每个 \(n\),输出一行一个整数,表示 \(S_1(n)\)…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把所有的那些数字打表出来. 逆序枚举就好 [代码] /* 1.Shoud it use long long ? 2.Have you ever test several sample(at least therr) yourself? 3.Can you promise that the solution is right? At least,the main ideal 4.use the puts("") or p…
Content 给定一个 \(1\sim n\) 的排列,请求出对于 \(1\leqslant m\leqslant n\),是否存在一个区间满足这个区间是一个 \(1\sim m\) 的排列. 数据范围:\(1\leqslant n,\sum n\leqslant 2\times 10^5\). Solution 看到本题的唯一一篇主席树+二分的题解里面并没有说最巧妙的方法是什么,那我就来给大家讲讲吧qwq. 对于每一个 \(m\),我们不妨弄个双指针 \(l,r\),然后从 \(1\) 的位…
Content 给定 \(n\) 个区间 \([l,r]\),求出每个区间内约数个数最大的数. 数据范围:\(1\leqslant l<r\leqslant 10^{10}\),\(r-l\leqslant 10^4\). Solution 你可能需要在做这题目前了解一下约数个数定理.何谓约数个数定理? 设一个数 \(x\) 的个数可以分解为若干个质因数相乘的积,即: \[x=\prod\limits_{i=1}^k p_i^{a_i} \] 那么 \(x\) 的约数个数 \(f(x)\) 有一…
题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只有成功了才会进入下一步,失败了会从第 \(1\) 步重新开始测.请问成功的期望步数是多少? 解题思路: 设期望步数是 \(S\) ,则有公式如下: 实现代码如下: #include <bits/stdc++.h> using namespace std; typedef long long ll;…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5179 题目大意: 给你一个数 \(A = a_1a_2 \cdots a_n\) ,我们称 \(A\) 为"漂亮的数"当且仅当 \(a[i] \ge a[i+1]\) (\(1 \le i \lt n\)) 并且 \(a[i]\) mod \(a[j] = 0\) (\(1 \le i \lt n, i \lt j \le n\)),比如 \(931\) 就是一个漂亮的数. 求区间 \([…