Perfect Pth Powers poj1730】的更多相关文章

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…
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],…
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…
题目链接: 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 =…
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…
/* 以前做的一道水题,再做精度控制又出了错///... */ 题目大意: 求最大完全平方数,一个数b(不超过int范围),n=b^p,使得给定n,p最大: 题目给你一个数n,求p : 解题思路: 不需要遍历b,只需要从31开始遍历p就好了.这个方法涉及到我以前过分逃避的精度控制问题:本题会使用函数pow 而pow的返回值是double转化成int 会有损失,比如4的double表示可以使4.00000000或者3.99999999999:而我们使用 强制类型转换会截取整数部分结果就可能是3,因…
这个有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) {…
题意: 对于32位有符号整数x,将其写成x = bp的形式,求p可能的最大值. 分析: 将x分解质因数,然后求所有指数的gcd即可. 对于负数还要再处理一下,负数求得的p必须是奇数才行. #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 <= m…
留坑(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…
https://vjudge.net/problem/UVA-10622 将n分解质因数,指数的gcd就是答案 如果n是负数,将答案除2至奇数 原理:(a*b)^p=a^p*b^p #include<cmath> #include<cstdio> #include<algorithm> #define N 65550 using namespace std; int gcd(int a,int b) { return !b ? a : gcd(b,a%b); } int…