题意:给定N个数a1,a2,a3...aN,现在要求最小的n满足 n!/(a1!*a2!*...*aN!) 是一个正整数的最小的n. 分析:这题的想法很明确,就是分解a1!*a2!*...*aN!,把其分解成质因子相乘的形式,这个都很熟悉了,然后就是对每一个质因子二分搜索出一个数字下界,最后求其中最大的一个数,问题的关键就是如何分解这样一个表达式成一个质因子相乘的形式.使用一个cnt数组来表示每一个数的在乘积中出现的次数,然后从后往前假设一个数出现了k次,那么如果这个数是素数则不用更新,如果一个…
链接: http://codeforces.com/problemset/problem/955/C 题意: Q次询问(1≤Q≤1e5),每次询问给出两个整数L, R(1≤L≤R≤1e18),求所有符合条件的整数x的个数.条件为:L≤x≤R,x = a的p次方(a, p为整数且a>0, p>1). 分析: 一.当指数p=3时,底数a最多有1e6个,由于指数增加时底数收敛得很快,所以我们可以将p>=3时的所有x放进vector里排序去重(预处理),求x的个数的时候二分查找即可.二.对于p=…
Codeforces Round #404 (Div. 2) 题意:对于 n and m (1 ≤ n, m ≤ 10^18)  找到 1) [n<= m] cout<<n; 2) [n>m]最小的 k => (k -m) * (k-m+1) >= (n-m)*2 成立 思路:二分搜索 #include <bits/stdc++.h> #include <map> using namespace std; #define LL long long…
题面: 传送门:http://codeforces.com/problemset/problem/475/D Given a sequence of integers a1, -, an and q queries x1, -, xq on it. For each query xi you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(al, al + 1, -, ar) = xi. 题目大意:…
传送门: http://codeforces.com/problemset/problem/600/B Queries about less or equal elements time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given two arrays of integers a and b. For e…
题目传送门 /* 二分查找/暴力:先埃氏筛选预处理,然后暴力对于每一行每一列的不是素数的二分查找最近的素数,更新最小值 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; ; const int INF = 0x3f3f3f3f; int a[MAXN][MAXN]; int mn_r[MAXN]; int mn_c[MAXN]; bool is_prim…
The link to problem:Problem - D - Codeforces   D. Range and Partition  time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Given an array a of n integers, find a range of values [x,y] (x≤y…
C. Primes on Interval time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positiv…
题目链接:http://codeforces.com/contest/732/problem/D 题意: 在m天中要考k个课程, 数组a中有m个元素,表示第a[i]表示第i天可以进行哪门考试,若a[i]为0,则表示当天不能参加任何科目的考试,只能预习或者休息: 数组b中有k个元素,b[i]表示科目i需要复习几天才能通过: 问最快需要几天能通过所有考试,如果不能完成所有科目考试,输出-1: 思路: 用二分方法直接找满足条件的最小的数,其中数是指当前天是第几天,条件是指当前天以前是否能考完所有科目(…
题目链接: http://codeforces.com/problemset/problem/484/B 题意: 求a[i]%a[j] (a[i]>a[j])的余数的最大值 分析: 要求余数的最大值非常明显a[i]越接近a[j]的倍数则余数越大 ,因此我们将全部的元素从大到小排序 : 然后枚举a[j]的倍数 ,二分查找小于a[i]倍数的最大值,然后更新余数的最大值. 代码例如以下: #include <iostream> #include <cstdio> #include…