Codeforces 1228C. Primes and Multiplication】的更多相关文章

传送门 当然是考虑 $n$ 的每个质数 $p$ 对答案的贡献 考虑 $p^k$ 在 $[1,m]$ 中出现了几次,显然是 $\left \lfloor \frac{m}{p^k} \right \rfloor$ 次 那么对于 $p^k$ ,它目前的贡献就是 $p^{\left \lfloor \frac{m}{p^k} \right \rfloor}$ ,注意这里不是 $p^{k\left \lfloor \frac{m}{p^k} \right \rfloor}$,因为之后计算对于 $k'<k…
题目链接:http://codeforces.com/contest/1228/problem/C 题解:给定一个函数f,g,题目有描述其中的表达式含义和两者之间的关系. 然后计算: 首先把给定的x用唯一分解定理分解出素因子 因为在1-n中,n/p(素因子)的值就是其1-n中有多少个数能整除p,n/p^2就是有多少个数能被p^2整除,所以做一次循环,每次n=n/p,直到n为0,sum记录每次n除以p的个数,就是1-n中能整除p的次方的数的幂指数之和了. 举个例子,45和3,n=45,p=3,第一…
C - Primes and Multiplication 思路:找到x的所有质数因子,用一个vector储存起来,然后对于每一个质因子来说,我们要找到它对最后的答案的贡献的大小,即要找到它在最后的乘积中出现了多少次. 求解方法: for(auto i:v) { ll cnt=0; ll temp=n/i; while(temp) cnt+=temp,temp/=i; ans=(ans*qpow(i,cnt))%mod; } 另外,该题还需要用到快速幂的技巧. ll qpow(ll x,ll n…
链接: https://codeforces.com/contest/1228/problem/C 题意: Let's introduce some definitions that will be needed later. Let prime(x) be the set of prime divisors of x. For example, prime(140)={2,5,7}, prime(169)={13}. Let g(x,p) be the maximum possible int…
题目地址:http://codeforces.com/contest/448/problem/D 当时是依照找规律做的,规律倒是找出来了,可是非常麻烦非常麻烦. . 看到前几名的红名爷们3分钟就过了,于是果断放弃了. .赛后才知道是用二分的方法做,知道了二分之后.剩下的就非常easy了..关键在于能不能想到用二分.. 代码例如以下: #include <iostream> #include <stdio.h> #include <string.h> #include &…
题目连接:https://codeforces.com/contest/1228/problem/C 题目大意:g(x,y)==y^k(其中y^k是X的最大可以整除因子) f(x,y)==g(x,p1)*(x,p2)....其中pi是x的第i个质因子 求f(x,1)*f(x,2)*f(x,3)---*f(x,n); 题解:对于整数N....N/x==从1到N可以被X整除的个数N/x^2同理... 所以我们不妨对每个质因子进行叠加,对于第一个p1,让N多次除以p1,同时记录可以整除的个数,最终我们…
题意:求使pi(n)*q<=rub(n)*p成立的最大的n. 先收集所有的质数和回文数.质数好搜集.回文数奇回文就0-9的数字,然后在头尾添加一个数.在x前后加a,就是x*10+a+a*pow(10,2).偶回文同理.然后不能二分,因为比值不是单调的. 乱码: #pragma comment(linker,"/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include…
题意 https://vjudge.net/problem/CodeForces-1228C 首先先介绍一些涉及到的定义: 定义prime(x)表示x的质因子集合.举例来说,prime(140)={2,5,7},prime(169)={13}. 定义g(x,p)表示存在一个最大的k∈N∗,使得x可以被p^k整除,那么g(x, p) = p^k.举例来说: g(45, 3) = 9 (45可以被3^2 = 9整除但是不能被3^3=27整除) g(63, 7) = 7 (63可以被7^1 = 7整除…
题目链接:https://www.luogu.org/problem/CF1228C 问题可以转化为:求质数 $p$ 在 $1\sim n$ 中的每个数中的次幂之和. 因为 $p$ 是一个质数,只能由 $1$ 乘以 $p$ 表示出来,所以可以将问题转化为求 $p$ 在 $n!$ 中出现的次幂. 我们可以像提取公因式一样地去提取这个 $p$. 那么,先考虑 $p$ 的贡献:$1\sim n$ 中能被 $p$ 整除的乘积为 $p^{\frac{n}{p}}\times (\frac{n}{p}!)$…
目录 Contest Info Solutions A. Distinct Digits B. Filling the Grid C. Primes and Multiplication D. Complete Tripartite E. Another Filling the Grid Contest Info Practice Link Solved A B C D E F 5/6 O O O O Ø - O 在比赛中通过 Ø 赛后通过 ! 尝试了但是失败了 - 没有尝试 Solutions…
https://codeforces.com/contest/1228/problem/A A. Distinct Digits 超级简单嘻嘻,给你一个l和r然后寻找一个数,这个数要满足的条件是它的每一位的数字不相同,找出满足要求的最小的那个数输出,没有找到就输出-1: #include<bits/stdc++.h> using namespace std; bool check(int n){ ]={}; while(n){ ]) vis[n%]=; else return false; n…
A. Multiplication Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/A Description Let's consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column co…
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://codeforces.com/contest/448/problem/D -----------------------------------------------------------------------------------------------…
Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Description Input Output Print exactly one integer — the beauty of the product of the strings. Sample Input 3aba Sample Output 3 题解:这个题的思维难度其实不大,需要维护什么东西很容易想到,或…
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic num…
链接: https://codeforces.com/contest/1220/problem/B 题意: Sasha grew up and went to first grade. To celebrate this event her mother bought her a multiplication table M with n rows and n columns such that Mij=ai⋅aj where a1,-,an is some sequence of positi…
A. Primes or Palindromes?Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=3261 Description Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindro…
http://codeforces.com/contest/448/problem/D 题意:一个n×m的矩阵,a[i][j]=i*j; 然后把a数组排序,找出第k个数. 思路:1-n×m二分枚举,然后统计比小于等于x的数的个数与k相比较. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #define maxn 1000100 #define ll…
 D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplication t…
主题链接:http://codeforces.com/contest/448/problem/D 思路:用二分法 code: #include<cstdio> #include<cmath> #include<iostream> using namespace std; __int64 n,m,k; __int64 f(__int64 x) { __int64 res=0; for(__int64 i=1;i<=n;i++) { __int64 minn=min(…
二分法判断答案 D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplicat…
题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n和m最大都是5e5那矩阵最大就有2e11不能够暴力,其实这里就应该想到要用二分做的,但是我做题的时候脑抽@.@想要推规律,然后就决决了.那么讲一下二分怎么做,就先简单的二分答案在(1-n*m)中二分,然后cheak函数中找所有矩阵中比所给值小的元素,个数大于等于k为成立条件.复杂度(O(n*log(…
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplication tabl…
Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Description Input Output Sample Input 51 2 1 2 1 Sample Output 1 1 1 2 2 题解:这个题有做慢了,这种题做慢了和没做出来区别不大... 读题的时候脑子里还意识到素数除了2都是奇数,读完之后就脑子里就只剩欧拉筛了,贪心地构造使得前缀和是连续的素数,那…
C. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and un…
题目链接: C. Primes or Palindromes? time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex…
ls特别喜欢素数,他总是喜欢把素数集合的所有子集写下来,并按照一定的顺序和格式.对于每一个子集,集合内 的元素在写下来时是按照升序排序的,对于若干个集合,则以集合元素之和作为第一关键字,集合的字典序作为第 二关键字(先比较集合第一个元素,再比较第二个元素,以此类推),这个序列的开始如下:[2], [3], [2, 3],  [5], [2, 5], [7], [3, 5], [2, 7], [2, 3, 5], [3, 7], [11], [2, 3, 7], [5, 7], [2, 11],…
Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the i…
C题, #include<cstdio> #include<cstring> #include<algorithm> #define maxn 5005 using namespace std; int num[maxn]; int rmq(int l,int r) { <<,tmp=l; for(int i=l;i<=r;i++) { if(ans>num[i]) { ans=num[i]; tmp=i; } } return tmp; } i…
题目:click here 题意:看hint就懂了 分析:数论小题,在n0.5时间里求n的质因子数 #include <bits/stdc++.h> using namespace std; typedef long long ll; int n, x; ll ans; void solve() { ans = ; ; i*i<=x; i++ ) { if( i <= n ) { && x/i <= n ) { ; ; } } else break; } pr…