首页 技术 正文
技术 2022年11月23日
0 收藏 771 点赞 3,846 浏览 979 个字

留坑(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").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = ; c = getchar(), !isdigit(c); ) if(c == '-') f = ;
for(x = ; isdigit(c); c = getchar()) x = x * + c - '';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; read(x); return x;
} typedef long long LL; LL qpow(LL a, LL b, LL Lim = ~0ull >> ) {
for(LL c = ; ; a *= a) {
if(b & ) c *= a;
if(!(b >>= )) return c;
if(c > Lim || a > Lim) return -;
}
} bool exist(LL x, LL p) {
int l = , r = ~0u >> ;
while(l <= r) {
int mid = l + (r - l) / ;
LL res = qpow(mid, p, x);
if(res == x) return ;
else if(res == - || res > x) r = mid - ;
else l = mid + ;
}
return ;
} int solve(LL n) {
if(n == ) return ;
int sign = ;
if(n < ) sign = -, n = -n;
for(int p = ; p >= ; p -= (sign > ? : )) {
if(exist(n, p)) return p;
}
return ;
} int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int n;
while(read(n)) {
printf("%d\n", solve(n));
} return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,996
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,510
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,353
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,137
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848