hdu4282A very hard mathematic problem 暴力枚举
来源:互联网 发布:poser pro 11 mac汉化 编辑:程序博客网 时间:2024/04/29 14:26
//给出k//找x,y,z使得x^z+y^z+x*y*z = k//x,y,z都为正整数x<y,z>1问有多少种方法//当z = 2时,可以看到左边是一个完全平方//而当z>=3时,可以暴力枚举x,y//由于k<2^31所以x<2^(31/3)枚举复杂度可以过#include<cstdio>#include<cstring>#include<iostream>#include<cmath>using namespace std ;const int maxn = 100 ;const int inf = 0x7fffffff ;typedef __int64 ll;ll pow(ll a , ll b){ ll c = 1; while(b) { if(b&1)c*=a; if(c > inf)return -1 ; b >>= 1; a *= a ; } return c ;}int main(){ int k; while(scanf("%d" ,&k) && k) { int ans = 0 ; int t = (int)sqrt((double)k) ; if(t*t == (double)k) ans += (int)(t-1)/2 ; for(ll i = 1;i*i*i < k ;i++) for(ll j = i + 1;j*j*j< k;j++) for(ll s = 3;;s++) { ll t1 = pow(i,s) ;ll t2 = pow(j , s) ; if(t1 == -1 || t2 == -1) break; if(t1 + t2 + i*j*s ==k) ans++ ; if(t1 + t2+ i*j*s > k) break; } printf("%d\n" ,ans) ; } return 0 ;}
0 0
- hdu4282A very hard mathematic problem 暴力枚举
- 【暴力搜索】-HDU-4282-a very hard mathematic problem
- HDU 4282 A very hard mathematic problem(暴力优化)
- hdu 4282 A very hard mathematic problem(二分+枚举)
- hdu 4282A very hard mathematic problem(枚举+二分)
- HDU4282 A very hard mathematic problem(枚举+二分)
- HDU-4282 A very hard mathematic problem 技巧枚举+二分
- A very hard mathematic problem
- A very hard mathematic problem
- hdu 4282 A very hard mathematic problem
- Hdu 4282 A very hard mathematic problem
- hdu4282 A very hard mathematic problem
- hdu 4282 A very hard mathematic problem
- hdu 4282 A very hard mathematic problem
- E - A very hard mathematic problem题解
- HDU 4282 A very hard mathematic problem
- hdu4282 A very hard mathematic problem
- A very hard mathematic problem(二分法)
- Android核心基础-6.Android 耗时操作
- Help Bob (141 - ZOJ Monthly, July 2015 )
- zoj1216
- 动态静态编联与virtual
- 购买 In-app Billing 商品
- hdu4282A very hard mathematic problem 暴力枚举
- 《开源框架那点事儿25》:对框架模板引擎实现方式的改造实录
- 跟我学Java多线程——ThreadLocal
- J2EE面试题集
- 并发处理的一些手段——转自百度百科
- 学习笔记——初识mybatis
- 发送电子邮件
- 黑马程序员----基础题----我的基础题
- 使用批处理映射网络盘