Codeforces301D. Yaroslav and Divisors】的更多相关文章

题意:2e5的全排列 每次询问一个区间有多少对数 满足一个数是另一个数的倍数 题解:考虑离线来做 看到有个说法说 在处理有两种约束的问题时 一般用数据结构边插入边询问的方式 这个题正是如此 我们用sum_i表示处理完1-i时所有的对数 那么可以用sum_r - sum_l-1得到一个答案 这个答案显然是多包含了一部分 一个数在前面 他的倍数在区间里这种方式 那么我们在插入到区间左端点的时候就可以很巧妙的 减去这一段贡献 插入到区间右端点的时候 加上一段贡献 #include <bits/stdc…
Yaroslav has an array p = p1, p2, ..., pn (1 ≤ pi ≤ n), consisting of n distinct integers. Also, he has m queries: Query number i is represented as a pair of integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the query li, ri is the number of pairs of…
Codeforces Round #182 (Div. 1) D:http://codeforces.com/contest/301/problem/D 题意:给一个1-n,n个数的序列,然后查询一个区间[l,r],问这个区间内有多少对:一个数是另外一个数的约数. 题解:这样的题目做的太少,自己也知道要用离线的数据结构,但是始终想不来,看了别人的代码也是半天没有看懂,最后还是请教了别人,才稍微明白一点.首先,对于[l,r]之间的数对来说,可以把1--r的数对减去1--l-1的数对,这是肯定的,但…
Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其中n个元素改变符号,你的目的是使得最后所有数的和尽量大,问你答案是多少 题解: 感觉上就是构造题,手动玩一玩就知道,当n为奇数的时候,你可以通过三次操作,使得只会改变一个负数的符号.同理n为偶数的时候,每次要改变两个负数的符号. 所以答案如下: 当n为奇数的时候,答案为所有数的绝对值和 当n为偶数的…
A. Eugeny and Array \(r-l+1\)是奇数时,和显然无法为0. 奇数的情况需要判断-1和1的个数是否大于等于长度的一半. B. Eugeny and Play List 模拟. C. Yaroslav and Sequence 当负数个数和\(n\)同奇偶时,所有数都可以转化成整数.(随便拿n-1个数和其中一个负数操作,然后再拿另一个负数和这n-1个数再操作即可).同奇偶,可以转变负数个数. 当负数为偶数时,最后都会变成整数. 否则,最后剩下一个负数时,与整数的最小值对换,…
E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Given the number n, find the smallest positive integer which has exactly n divisors. It is guara…
Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers. Now given a humble number, please write…
计算小于n的数中,约数个数最多的数,若有多个最输出最小的一个数. http://hihocoder.com/problemset/problem/1187 对于100有 60 = 2 * 2 * 3 * 5,共 (2 + 1) * (1 + 1) * (1 + 1) = 12个约数. 对于 n <= 10 ^ 16,int最大值为10位,所以这里要用long long.很显然:约数要尽量小,然后小的约数的指数一定大于大的约数的指数. 所以对于 10^16,有质因子:2,3,5,7,11,13,1…
Xenia and Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the mathematician has a sequence consisting of n (n is divisible by 3) positive integers, each of them is at most 7…
传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given an integer n, for all integers not larger than n, find the integer with the most divisors. If there is more than one integer with the same number of divisors, print the minimum one. 输入 One line with an…
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2044    Accepted Submission(s): 1006 Problem DescriptionA number whose only prime factors are 2,3,…
Problem Description mmm is learning division, she's so proud of herself that she can figure out the sum of all the divisors of numbers no larger than 100 within one day!But her teacher said "What if I ask you to give not only the sum but the square-s…
B. Petya and Divisors Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/111/problem/B Description Little Petya loves looking for numbers' divisors. One day Petya came across the following problem: You are given n queries in t…
题意: 求区间[L, U]的正因数的个数. 分析: 有这样一条公式,将n分解为,则n的正因数的个数为 事先打好素数表,按照上面的公式统计出最大值即可. #include <cstdio> #include <cmath> ; ]; ], cnt = ; void Init() { int m = sqrt(maxn + 0.5); ; i <= m; ++i) if(!vis[i]) for(int j = i * i; j <= maxn; j += i) vis[j…
Sum of divisors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2063    Accepted Submission(s): 718 Problem Description mmm is learning division, she's so proud of herself that she can figure o…
涉及知识点: 1. 进制转换. 2. 找因子时注意可以降低复杂度. Sum of divisors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4837    Accepted Submission(s): 1589 Problem Description mmm is learning division, she's so prou…
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3033    Accepted Submission(s): 1465 Problem Description A number whose only prime factors are 2,3…
ZOJ 2562 More Divisors(高合成数) ACM 题目地址:ZOJ 2562 More Divisors 题意:  求小于n的最大的高合成数,高合成数指一类整数,不论什么比它小的自然数的因子数目均比这个数的因子数目少. 分析:  网上都叫它反素数,事实上我查了一下,翻素数应该是正着写倒着写都是素数的素数.这个应该叫高合成数,见Wikipedia: Highly composite number 高合成数有下面特征:  where p1<p2<⋯<pk are prime,…
More Divisors Time Limit: 2 Seconds      Memory Limit: 65536 KB Everybody knows that we use decimal notation, i.e. the base of our notation is 10. Historians say that it is so because men have ten fingers. Maybe they are right. However, this is often…
CodeForces - 27E Number With The Given Amount Of Divisors Submit Status Description Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018. Input The…
题目连接 The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3416 Accepted Submission(s): 1676 Problem Description A number whose only prime factors are 2,3…
Divisors Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9940   Accepted: 2924 Description Your task in this problem is to determine the number of divisors of Cnk. Just for fun -- or do you need any special reason for such a useful compu…
Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1604    Accepted Submission(s): 592 Problem Description In mathematics, the function d(n) denotes the number of divisors of p…
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…
G. The jar of divisors time limit per test:2 seconds memory limit per test:64 megabytes input:standard input output:standard output Alice and Bob play the following game. They choose a number N to play with. The rules are as follows: - They write eac…
题目链接:E. Divisors 题意: 给出一个X,f(X)是X所有约数的数列(例6:1 2 3 6),给出一个k,k是递归的次数(例:k=2 : f(f(X)) ; X=4,k=2: 1 1 2 1 2 4 ), X (1 ≤ X ≤ 10^12) and k (0 ≤ k ≤ 10^18).现在给出X与k让你求这个序列,序列长度如果超过1e5就只存1e5个数. 题解: 这个题的话除了DFS没有想到特别好的方法,但是问题是强行DFS时间会超@.@.(DFS思路:处理出dfs时数的所有约数(n…
题目链接:1033D - Divisors 题目大意:给定\(n\)个数\(a_i\),每个数的约数个数为3到5个,求\(\prod_{i=1}^{n}a_i\)的约数个数.其中\(1 \leq n \leq 500 , 1 \leq a_i \leq 2\cdot 10^{18}\). 题解:考虑约数个数公式,可以发现对于任意的\(a_i\),有\(a_i=\left\{\begin{matrix}p^2\\ p^3\\ p^4\\ p_1\cdot p_2\end{matrix}\right…
Recently you have received two positive integer numbers xx and yy. You forgot them, but you remembered a shuffled list containing all divisors of xx (including 11 and xx) and all divisors of yy (including 11 and yy). If dd is a divisor of both number…
Yaroslav and Points 明明区间合并一下就好的东西, 为什么我会写得这么麻烦的方法啊啊啊. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int>…
D. Divisors http://codeforces.com/contest/1033/problem/D 题意: 给n个(n<=500)个数,($a_i <= 2 \times 10 ^ {18}$),每个数的因数个数在[3,5]内.$a = \prod\limits_{i=1}^na_i$,求a的因数个数. 分析: 首先有一个结论:一个数x的质因数分解后为:$x = p_1^{a_1}p_2^{a_2}...p_k^{a_k}$ 那么它的因数个数就是 $(a_1 + 1) \time…