zoukankan      html  css  js  c++  java
  • The Super Powers

    Time Limit: 1000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu

    []   [Go Back]   [Status]  

    Description

     

    A

    The Super Powers

     

    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 = 82 and 64 =  43. You have to write a program that lists all super powers within 1 and 264 -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. 

    Sample Input                              

    Partial Judge Output

    No input for this problem   

     

    1

    16
    64

    81
    256

    512
    .
    .
    .

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<set>
     4 #include<math.h>
     5 #include<iostream>
     6 #include<algorithm>
     7 using namespace std;
     8 #define  ll unsigned long long
     9 int a[100]= {0},nu;
    10 void init()
    11 {
    12     int i,j;
    13     nu=0;
    14     for(i=2; i<100; i++)
    15     {
    16         if(!a[i])
    17         {
    18             j=i*i;
    19             while(j<100)
    20             {
    21                 a[j]=1;
    22                 j+=i;
    23             }
    24         }
    25     }
    26     j=0;
    27     for(i=4; i<65; i++)if(a[i])a[j++]=i;
    28     //for(i=0; i<j; i++)cout<<a[i]<<endl;
    29     nu=j;
    30 }
    31 ll powLL(ll x, ll y)
    32 {
    33     ll ans=1;
    34     while(y)
    35     {
    36         if(y&1)
    37         ans*=x;
    38         x*=x;
    39         y>>=1;
    40     }
    41     return ans;
    42 }
    43 int main()
    44 {
    45     init();
    46     int i,j,size;
    47     ll  maxa=~0ULL,n;
    48     //cout<<maxa<<endl;
    49     set<ll>aa;
    50     aa.clear();
    51     aa.insert(1);
    52     for(i=2;;i++)
    53     {
    54         size=0;
    55         n=maxa;
    56         while(n>=i) n/=i,size++;
    57         if(size<4) break;
    58         for(j=0;j<nu;j++)
    59         {
    60             if(a[j]<=size)
    61             aa.insert(powLL(i, a[j]));
    62             else break;
    63         }
    64     }
    65     for(set<ll>::iterator it=aa.begin();it!=aa.end();it++)
    66     printf("%llu
    ",*it);
    67 }
    View Code
  • 相关阅读:
    iframe自适应高度的多种方法方法
    [tomcat][mysql][JDK][maven][myEclipse][ubuntu][centOs][oracle]等下载地址整理
    解决电脑速度越来越慢的方法
    li:hover 上再IE6下就没有效果的解决方法
    各种常用文件后缀名详解
    ASP.net中网站访问量统计方法
    RabbbitMQ的配置 以在.NetCore 的CAP 使用RabbbitMQ 实现订阅与发布问题
    .netCore 根据模型生成数据库
    jsonp Ajax跨域请求
    IE8 placeholder兼容+Password兼容
  • 原文地址:https://www.cnblogs.com/ERKE/p/3700280.html
Copyright © 2011-2022 走看看