传送门 •题意 给你一个大于 1 的正整数 n: 它可以分解成不同的质因子的幂的乘积的形式,问这些质因子的幂中,最小的幂是多少. •题解 定义 $ans$ 表示最终答案: ①如果 $ans \ge 5$: 那么,肯定有 $n=p^{ans}\ ,\ p \le \sqrt[{ans}]{n}$,也就是说 $\ p \le 10^{\frac{18}{5}}$: 所以,我们可以提前预处理出 $[1,10000]$ 内的素数,筛出 $n$ 中属于 $[1,10000]$ 内的质因子: 如果在这个过程…
传送门 •题意 给你一个大于 1 的正整数 n: 它可以分解成不同的质因子的幂的乘积的形式,问这些质因子的幂中,最小的幂是多少. •题解 把[1,10000]内的素数筛出来,然后对于每个素$P$数遍历找$P_{k}$的$k$,用$ans$来维护最小的$k$ 对于大于10000的素数,$(10^{4})^{4}<10^{18}<(10^{4})^{5}$,所以最大是4次方 先看4次方: 若$x^{4}==n$,则$x$一定是素数,为什么是素数? 根据欧拉定理,一个数可以分成若干个素数乘积的形式.…
Time limit 1000 ms Memory limit 65536 kB OS Windows 中文题意 给一个数n,设将n质因数分解后可以得到 \[n=\prod_{i=1}^{\omega(n)} a_i^{p_i}\] 其中\(\omega(n)\)意思是n的不同质因子个数,\(a_i\)是n的质因子. 要求输出最小的\(p_i\). 题解 看完题解感觉很妙啊-- Let's first factorize \(N\) using prime numbers not larger…
题意: 已知任意大于\(1\)的整数\(a = p_1^{q_1}p_2^{q_2} \cdots p_k^{q_k}\),现给出\(a \in [2,1e18]\),求\(min\{q_i\},q \in [1, k]\).即求质因数分解后,最小指数是多少. 思路: 因为\(a \in [2,1e18]\),所以我们现打一个\(1e4\)以内的质数表,然后直接求出\(1e4\)以内的情况. 上面弄完了,那么现在最多只有\(4\)个质因子,情况如下: \(n = p^4\),这种情况就是\(4\…
Minimal Power of Prime 题目传送门 解题思路 先打\(N^\frac{1}{5}\)内的素数表,对于每一个n,先分解\(N^\frac{1}{5}\)范围内的素数,分解完后n变为m,如果m等于1,那么答案就是\(N^\frac{1}{5}\)内分解的素数里的最小数量k.否则,继续分解,此时用来分解的质数都是大于\(N^\frac{1}{5}\)的,所以最多有4个质数相乘,所以只有三种情况:\(P^4\),\(P^3\),\(P^2\),\(P^2*Q^2\),以及答案为1的…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6623 题目大意为求一个数的唯一分解的最小幂次.即120=23*31*51则答案为1. 因为数字太大不能直接分解,所以可以先分解1e4内的素因子,这样所有幂次可能>=5的数都被分解了,然后判断剩余的数是否是一个数的4次方如果是的话ans=min(ans,4), 如果不是的话再判断是不是一个数的3次方,如果是的话ans=min(ans,3). 如果不是的话就判断是不是一个数的平方,如果是ans=min(…
http://acm.hdu.edu.cn/showproblem.php?pid=6623 题意,给50000个1e18级别的数N,求它质因数分解里面的最小的指数(不算0) 比赛的时候给划了一个1e6以内的暴力判断,判断失效之后开平方根看看是不是质数平方,是则2不是则1.这个是题解的最后一步. 可惜没办法沿着这个思路走,就开始自闭了. 其实先暴力判断掉N的1/5次方内的质因数的指数,假如是1则直接退出了,否则要么不出现要么出现至少是2,记录剩余的数字为M.显然M是与N同级别的. 由于暴力掉了N…
题目 将 $n$($1 < n \leq 10^{18}$)质因数分解,求质因数幂的最小值. 分析 直接质因数分解,不太行. 可以这样想,对小区间质因数分解,n变小了,再枚举答案. 打印1-10000之间的素数表然后质因数分解,分解完剩下的那个数, 两种质数(肯定大于 $10^4$)相乘,最多二次,合起来也是一个平方数: 三种或以上质数相乘,只可能为一次,不用考虑. 一种质数,最多为四次方,枚举四.三.二次方,如果都不是,就是单个质数 要注意:先看是4次方再看2次方(因为如果满足4次方一定满足2…
题目链接:Click here 题目大意:求一个数分解质因数后的最小幂指数 Solution: 首先,我们肯定是不能直接暴力求解的 我们先考虑筛出1e4范围以内的所有质数,把x所有这个范围内的质因子筛掉 那么现在它的数值范围就变成了1e14了,考虑此时他还存在没有被筛掉的质因子的情况 因为我们已经筛掉了1e4以内的质数,所以此时它的质因子的大小是大于1e4的,那么它的指数大小最大为4 我们可以直接对此时的x开根来判断指数是否为2.4,对于指数为3的情况我们则二分判断,若都不满足,则他为质数 Co…
题意:给定大整数n,求其质因数分解的最小质数幂 n<=1e18 思路:常规分解算法肯定不行 考虑答案大于1的情况只有3种:质数的完全平方,质数的完全立方,以及p^2*q^3,p,q>=1三种形式 前两种可以暴力判 第三种必定有一个小于10^(18/5)的因子,大概是3800 迭代分解,用vector存一下具体的情况 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned…
题目链接 题意:输入n,求所有质因子幂的最小值.n奇大无比. 思路:先对n所有n开五次方根的质因子约完,然后如果没有除尽的话,因子最多也就4个了,所以幂数大于1的情况有p1^4,p1^3, p1^2  对于其他情况肯定有幂为1的. 然后注意一下精度问题. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #define…
题面 T ≤ 50   000 T\leq50\,000 T≤50000 组数据: 输入一个数 N N N ( 2 ≤ N ≤ 1 0 18 2\leq N\leq 10^{18} 2≤N≤1018),输出一个数,表示 N N N 质因数分解后,每个质因数的幂的最小值. 题解 妙妙题! 一种神奇的做法: 我们把 N 5 < 3   982 \sqrt[5]{N}<3\,982 5N ​<3982 以内的质数都筛出来,以便把 N N N 的 ≤ N 5 \leq\sqrt[5]{N} ≤5…
/* HDU 6034 - Balala Power! [ 大数进位,贪心 ] 题意: 给一组字符串(小写英文字母),将上面的字符串考虑成26进制数,每个字母分配一个权值,问这组数字加起来的和最大是多少? 要求每个数字不能有前导0,即每个字符串首位字符不能赋0 分析: 对于每个字符,将每个字符串按位相加,得到这个字符的一个每位上的数量的数组 将其看成一个大数,满26进位,然后排序,从高到低赋值,注意考虑0 */ #include <bits/stdc++.h> using namespace…
Power of Cryptography  Background Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers modulo functions of these primes. Work in this area has resulted in the practical use of results from num…
http://acm.hdu.edu.cn/showproblem.php?pid=2489 这道题就是n个点中选择m个点形成一个生成树使得生成树的ratio最小.暴力枚举+最小生成树. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 1000 using namespace std; <<; ; int map[maxn][maxn]; int g[maxn][m…
Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2668    Accepted Submission(s): 562 Problem Description Sample Input 1 a 2 aa bb 3 a ba abc Sample Output Case #1: 25 Case #2: 132…
Special Prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 738    Accepted Submission(s): 390 Problem Description Give you a prime number p, if you could find some natural number (0 is not in…
History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 434264-bit integer IO format: %I64d      Java class name: Main Prev Submit Status Statistics Discuss Next Type: None   None Graph Theory 2…
find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7403    Accepted Submission(s): 2120 Problem Description 假设:S1 = 1S2 = 12S3 = 123S4 = 1234.........S9 = 123456789S10 = 12345678…
Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1411    Accepted Submission(s): 239 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters.…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2489 Problem Description For a tree, which nodes and edges are all weighted, the ratio of it is calculated according to the following equation. Given a complete graph of n nodes with all nodes and edges…
2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Acesrc is a famous mathematician at Nanjing University second to none. Playing with interesting numbers is his favorite. Today, he finds a manuscript whe…
http://acm.hdu.edu.cn/showproblem.php?pid=2138 题意:给n个数判断有几个素数.(每个数<=2^32) #include <cstdio> using namespace std; typedef long long ll; ll ipow(ll a, ll b, ll m) { ll x=1; for(; b; b>>=1, (a*=a)%=m) if(b&1) (x*=a)%=m; return x; } ll rand…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019 Problem Description In mathematics, the greatest common divisor (gcd), also known as the greatest common factor (gcf), highest common factor (hcf), or greatest common measure (gcm), of two or more i…
Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5476 Description In Geometry, the problem of track is very interesting. Because in some cases, the track of point may be beautiful curve. For…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4091 /** 这题的一种思路就是枚举了: 基于这样一个事实:求出lcm = lcm(s1,s2), num1 = lcm/s1, num2 = lcm/s2; 则价值与体积比小的那个宝藏个数一定大于lcm/size;这个用反证法就可证明. 然后就是只需要枚举N%lcm + lcm这个体积的最有分配. */ #include<cstdio> #include<cstring> #incl…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4099 这个题目就是一个坑或. 题意:给你不超过40的一串数字,问你这串数字是Fibonacci多少的开头几位数字,如果不存在则输出-1. 题解:明明说好的不超过40,但是在建字典数的时候不加i<41就超内存了,杭电你是想咋地,害的我比较好多人的代码,一点一点试出来的. AC代码: #include <iostream> #include <cstdio> #include <…
Problem Description   You live in a village but work in another village. You decided to follow the straight path between your house (A) and the working place (B), but there are several rivers you need to cross. Assume B is to the right of A, and all…
题目链接: POJ:id=3100" style="font-size:18px">http://poj.org/problem? id=3100 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1818 HDU:pid=2740">http://acm.hdu.edu.cn/showproblem.php?pid=2740 Description Given positive…
Minimal Ratio Tree Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 12   Accepted Submission(s) : 7 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description For a tree, which n…