zoukankan      html  css  js  c++  java
  • 2017ACM/ICPC广西邀请赛 A Math Problem

    A Math Problem

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 0    Accepted Submission(s): 0


    Problem Description
    You are given a positive integer n, please count how many positive integers k satisfy kkn .
     
    Input
    There are no more than 50 test cases.

    Each case only contains a positivse integer n in a line.

    1n1018
     
    Output
    For each test case, output an integer indicates the number of positive integers k satisfy kkn in a line.
     
    Sample Input
    1 4
     
    Sample Output
    1 2
     
     
    题解:完全是一道水题
    10的18次方   所以我们使用long long int 长整数打表    记录i的i次方    我们可以发现当i=16的时候   16的16次方已经大于了10的18次方
    直接打表循环判断一下就AC了
     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <stdlib.h>
     4 #include <algorithm>
     5 #include <cstring>
     6 #include <math.h>
     7 using namespace std;
     8  long long int a[20];
     9  long long int jug(int x)
    10 {
    11    long long int ans=1;
    12     for(int i=1;i<=x;++i)
    13     {
    14         ans=ans*x;
    15     }
    16     return ans;
    17 }
    18 void init()
    19 {
    20     for(int i=1;i<20;++i)
    21     {
    22         a[i]=jug(i);
    23     }
    24 }
    25 int main()
    26 {
    27     init();
    28   long long int n;
    29 
    30     while(~scanf("%lld",&n))
    31     {
    32         for(int i=1;i<=15;++i)
    33         {
    34             if(a[i]>n)
    35             {
    36                 printf("%d
    ",i-1);
    37                 break;
    38             }
    39         }
    40         if(a[15]<=n)
    41         printf("15
    ");
    42     }
    43      return 0;
    44 }
    45 //0ms  AC

    喜欢算法的dalao可以加QQ1345411028

  • 相关阅读:
    Openlayer 3 的画图测量面积
    Openlayer 3 的画线测量长度
    屏幕尺寸
    px和em,rem的区别
    水平和垂直居中
    Flex布局
    继承的几种方法及优缺点
    call ,apply 和 bind的用法与区别
    mybatis springmvc velocity的demo
    正则同时包含两个关键字
  • 原文地址:https://www.cnblogs.com/52why/p/7459967.html
Copyright © 2011-2022 走看看