题目链接: https://cn.vjudge.net/problem/POJ-1730 题目描述: We say that x is a perfect square if, for some integer b, x = b 2. Similarly, x is a perfect cube if, for some integer b, x = b 3. More generally, x is a perfect pth power if, for some integer b, x =…
http://poj.org/problem?id=1730 题意:给出一个n,a=b^p,求出最大p值. 思路: 首先利用唯一分解定理,把n写成若干个素数相乘的形势.接下来对于每个指数求最大公约数,该公约数就是所能到达的最大p值. 有一点要注意的是如果n为负数的话,如果当前p值为偶数,就一直除2直到p为奇数. #include<iostream> #include<algorithm> #include<string> #include<cstring>…
这个有2种方法. 一种是通过枚举p的值(p的范围是从1-32),这样不会超时,再就是注意下精度用1e-8就可以了,还有要注意负数的处理…… #include<iostream> #include<stdio.h> #include<algorithm> #include<cmath> #include<iomanip> #include<string> using namespace std; int fun(double n) {…
UVA 10622 - Perfect P-th Powers 题目链接 题意:求n转化为b^p最大的p值 思路:对n分解质因子,然后取全部质因子个数的gcd就是答案,可是这题有个坑啊.就是输入的能够是负数,负数的情况比較特殊,p仅仅能为奇数.这时候是要把答案不断除2除到为奇数就可以. 代码: #include <stdio.h> #include <string.h> #include <math.h> long long n; int prime[333333],…
Perfect Pth Powers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16383   Accepted: 3712 Description We say that x is a perfect square if, for some integer b, x = b2. Similarly, x is a perfect cube if, for some integer b, x = b3. More g…
We say that x is a perfect square if, for some integer b, x = b 2. Similarly, x is a perfect cube if, for some integer b, x = b 3. More generally, x is a perfect pth power if, for some integer b, x = b p. Given an integer x you are to determine the l…
We say that x is a perfect square if, for some integer b, x = b2. Similarly, x is a perfect cube if, for some integer b, x = b3. More generally, x is a perfect pth power if, for some integer b, x = bp. Given an integer x you are to determine the larg…
题目链接:http://poj.org/problem?id=3279 Sample Input 4 4 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 Sample Output 0 0 0 0 1 0 0 1 1 0 0 1 0 0 0 0 题意: 给出 $M$ 行 $N$ 的矩阵,每个元素只为 $0$ 或者 $1$,分别代表白块和黑块, 每次可以翻转一个元素,使得它可以从黑变白或者从白变黑,但是上下左右相邻的四个元素也会跟着翻转, 求最少翻转多少个元素,可以使得全部元素均变…
留坑(p.343) 完全不知道哪里有问题qwq 从31向下开始枚举p,二分找存在性,或者数学函数什么的也兹辞啊 #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<iostream> using namespace std; void setIO(const string& s) { freopen((s + ".in…
Equipment Box 题目链接: http://acm.hust.edu.cn/vjudge/contest/130510#problem/B Description There is a large room in the Pyramid called Room-of-No-Return. Its floor is covered by rectangular tiles of equal size. The name of the room was chosen because of…