Divisor
[LeetCode] 1979. Find Greatest Common Divisor of Array
Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. The greatest common divisor of two ......
cf1864C. Divisor Chain
https://codeforces.com/contest/1864/problem/C 思维越来越僵化了 假如\(n=2^k\),直接每次/2就行。 否则,我们可以考虑如何转化成上面的情况 令\(n=2^k x\),那么我们显然可以转移到\(n=2^k (x-1)\),因为x是奇数,所以2的次幂 ......
Codeforces Round 697 (Div. 3) A. Odd Divisor
给定一个正整数 \(n\) ,询问是否存在一个 \(> 1\) 的奇数因子。 在唯一分解定理下观察 \(n\) ,发现若存在除 \(2\) 以外的质因子,则 \(n\) 存在 \(> 1\) 的奇数因子。 换句话说 \(n\) 不是二次幂形式则存在 \(> 1\) 的奇数因子。 view #incl ......
Codeforces Round 697 (Div. 3) A. Odd Divisor
给一个正整数 \(n\) ,判断 \(n\) 是否存在一个 \(> 1\) 的奇数因子。 只要 \(n\) 的唯一分解下存在除 \(2\) 以外的质因子,则 \(n\) 存在 \(>1\) 的奇数因子。 于是 \(n \neq lowbit(n)\) 则 \(n\) 存在奇数因子。(应用了 \(2^ ......
题解 CF1257G【Divisor Set】
problem 我们说一个集合 \(D\) 是一个好的集合,当不存在集合中的两个不同元素 \(a,b\) 使得 \(a\) 是 \(b\) 的约数。 给定一个超大整数的素数表示形式 \(N = \prod_{i=1}^n{p_i}\),要求从它的所有因子中选择尽可能多的元素组成一个好的集合。 问这个 ......
CF1864C Divisor Chain
原题 翻译 好题难想 首先考虑\(x = 2^k\)怎么做,显然每次\(- 2^{k-1}\)即可 然后我们考虑对于\(x \neq 2^k\)怎么把他变成\(2^k\),答案就是\(x -= lowbit(x)\) 操作次数\(O(logn)\)的,\(< 1000\),正确性显然 ......
CF1864C Divisor Chain 题解
## 题意 给定一个整数 $x$,定义一个操作: > 选择一个 $x$ 的因数 $d$,把 $x$ 修改为 $x-d$。 限制相同的 $d$ 值不能选择超过 $2$ 次,需要在最多 $1000$ 次操作内把 $x$ 操作至 $1$,求操作序列。 ($1 \le x \le 10^9$)。 ## 题解 ......
CF1864C Divisor Chain
## 思路 刚拿到题,想了一些方法但都被推翻了,在这里列举出来,并给出反例: - 每次减去最小的因数,反例:$1024$ 等形如 $a^k$ 的数,每次都会减去 $a$ 导致 $a$ 的出现次数超过 $2$ 次。 - 每次减去大于等于 $\sqrt x$ 的因子,$x$ 为目前的数,并特判指数的情况 ......
[LeetCode] 1071. Greatest Common Divisor of Strings
For two strings s and t, we say "t divides s" if and only if s = t + ... + t (i.e., t is concatenated with itself one or more times). Given two string ......
[数论]Divisor and Gcd
## Divisor and Gcd ### 1、算术基本定理:n的质因数分解唯一 一些常见结论: 1.素数无限 2.$\lim_{n\rightarrow+\infty}n\prod\dfrac{n}{\frac{n}{\ln{n}}}$(Π(n)表示 ab|c$ 3.$a|bc,(a,b) = ......