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
  • 相关阅读:
    Chrome使用video无法正常播放MP4视频的解决方案
    ArcGIS 按掩膜裁剪地形
    bilibili 分P视频 需下载哔哩哔哩投稿工具
    U盘/硬盘数据恢复
    visio 2010、2013、2016、2019安装包
    经纬度WGS84地理坐标系转换成CGCS2000坐标系步骤,必备!
    Git 配置多个用户邮箱以及在 Sourcetree 中使用
    Chrome 插件 一键保存当前打开的所有标签页
    Cesium粒子系统学习
    破解ArcGIS坐标系之惑: 从基本概念到常用操作
  • 原文地址:https://www.cnblogs.com/ERKE/p/3700280.html
Copyright © 2011-2022 走看看