uva 11752 The Super Powers
2016-08-11 14:02
351 查看
原题:
We all know the Super Powers of this world and how they manage to get advantages in political warfare
or even in other sectors. But this is not a political platform and so we will talk about a different kind
of super powers — “The Super Power Numbers”. A positive number is said to be super power when it
is the power of at least two different positive integers. For example 64 is a super power as 64 = 8 2 and
64 = 4 3 . You have to write a program that lists all super powers within 1 and 2 64 − 1 (inclusive).
Input
This program has no input.
Output
Print all the Super Power Numbers within 1 and 2 64 − 1. Each line contains a single super power
number and the numbers are printed in ascending order.
Note: Remember that there are no input for this problem. The sample output is only a partial solution.
Sample Input
Sample Output
1
16
64
81
256
512
.
.
.
中文:
找出所有1到2^64-1的范围当中的一个数,这个数可以表示为a^x和b^y。没有输入
解答:
只要找出一个数,让他的次幂数是一个合数即可。但是程序没写出来,看别人题解明白了。每次都用2^64-1不断去除一个数,除了多少次,就是这个数的次幂数。放入set中去重即可。
We all know the Super Powers of this world and how they manage to get advantages in political warfare
or even in other sectors. But this is not a political platform and so we will talk about a different kind
of super powers — “The Super Power Numbers”. A positive number is said to be super power when it
is the power of at least two different positive integers. For example 64 is a super power as 64 = 8 2 and
64 = 4 3 . You have to write a program that lists all super powers within 1 and 2 64 − 1 (inclusive).
Input
This program has no input.
Output
Print all the Super Power Numbers within 1 and 2 64 − 1. Each line contains a single super power
number and the numbers are printed in ascending order.
Note: Remember that there are no input for this problem. The sample output is only a partial solution.
Sample Input
Sample Output
1
16
64
81
256
512
.
.
.
中文:
找出所有1到2^64-1的范围当中的一个数,这个数可以表示为a^x和b^y。没有输入
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; int p[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61}; int vis[70]; const ull maxn=(2<<64)-1; set<ull> ans; int main() { ios::sync_with_stdio(false); ans.insert(1); for(int i=0;i<18;i++) vis[p[i]]=1; for(ull i=2;;i++) { ull tmp=maxn; int ind=-1; while(tmp) { tmp/=i; ind++; } if(ind<4) break; tmp=i; for(ull j=2;j<=ind;j++) { tmp*=i; if(!vis[j]) ans.insert(tmp); } } for(auto x:ans) cout<<x<<endl; return 0; }
解答:
只要找出一个数,让他的次幂数是一个合数即可。但是程序没写出来,看别人题解明白了。每次都用2^64-1不断去除一个数,除了多少次,就是这个数的次幂数。放入set中去重即可。
相关文章推荐
- uva 11752 The Super Powers
- UVA 11752 The Super Powers 超级幂
- UVa 11752 (素数筛选 快速幂) The Super Powers
- UVA11752-The Super Powers(素数表+log)
- The Super Powers UVA 11752 分析分析 求无符号长整形以内的数满足至少可以用两种不同的次方来表示。比如64 = 2^6 = 8^2; 一个数的1次方不算数。
- uva 11752 - The Super Powers(数论+枚举技巧)
- UVA 11752 The Super Powers
- UVa 11752 The Super Powers(数学)
- UVA 11752 The Super Powers
- UVA - 11752 The Super Powers
- UVA 11752 The Super Powers
- UVa 11752 The Super Powers (数学)
- UVA - 11752 The Super Powers
- Uva 11752 The Super Powers
- Uva 11752 The Super Powers 解题报告(数学)
- UVA 11752 The Super Powers【超级幂】
- UVA 11752-The Super Powers
- UVA 11752 The Super Powers【超级幂】
- The Super Powers UVA - 11752 (素数分解)
- uva 11752 -The Super Powers (数论)