Codeforces 762A k-th divisor(数论)】的更多相关文章

time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist. Divisor of n is any such natural number, t…
[题目链接] 点击打开链接 [算法] 我们知道,一个数的因子是成对出现的,一半小于等于sqrt(N),一半大于sqrt(N),因此,我们可以从 2..sqrt(N)枚举因子 [代码] #include<bits/stdc++.h> using namespace std; #define MAX 3000000 typedef long long ll; ll i,l,n,k; ll a[MAX+]; template <typename T> inline void read(T…
Codeforces 762A 题目大意: 给定两个正整数n,k\((n \le 10^{15},k\leq10^9)\),求n的从小到大的第k个约数,无解输出-1 分析: 我们会自然而然地想到找出n的所有的约数,然后取第k个. 我们发现如果这样的话时间复杂度为\(O(\sqrt{n})\),空间复杂度为\(O(lnn)\) 所以我们暴力上就好了 #include <cstdio> #include <cstring> #include <algorithm> usin…
[CodeForces - 1225D]Power Products [数论] [分解质因数] 标签:题解 codeforces题解 数论 题目描述 Time limit 2000 ms Memory limit 524288 kB Source Technocup 2020 - Elimination Round 2 Tags hashing math number theory *1900 Site https://codeforces.com/problemset/problem/1225…
Bash and a Tough Math Puzzle CodeForces 914D 线段树+gcd数论 题意 给你一段数,然后小明去猜某一区间内的gcd,这里不一定是准确值,如果在这个区间内改变一个数的值(注意不是真的改变),使得这个区间的gcd是小明所猜的数也算小明猜对.另一种操作就是真的修改某一点的值. 解题思路 这里我们使用线段树,维护区间内的gcd,判断的时候需要判断这个区间的左右子区间的gcd是不是小明猜的数的倍数或者就是小明猜的数,如果是,那么小明猜对了.否则就需要进入这个区间…
题目链接:k-th divisor 求出N的第K大因子,满足N <= 10^15,K <= 10^9 直接暴力…… #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i(a); i <= (b); ++i) #define LL long long LL n, k, h, ans; int num; int main(){ scanf("%lld%lld", &…
传送:http://codeforces.com/gym/102152/problem/K 题意:给定$n(n\le10^5)$个数$a_i(a_i\le10^9)$,对于任一个子数组中的数进行或操作,问所有的值有多少种? 分析: 假设现在想要求解区间$[1,i]$内的答案,那么需要先处理出$[1,i-1],[2,i-1],[3,i-1]......[i-1,i-1]$.然后将这些答案暴力与$a_i$取$|$. 代码: #include<bits/stdc++.h> using namespa…
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it fast…
Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b. Vasya has two numbers x and y, and he wants to calculate f(x, y).…
Let's call the roundness of the number the number of zeros to which it ends. You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible. Input…