zoukankan      html  css  js  c++  java
  • CodeForces 614A Link/Cut Tree

    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<stack>
    #include<vector>
    #include<string>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    
    long long L,R,K;
    
    long long POW(long long m,long long n)
    {
        long long b=1;
         while (n)
        {
              if (n & 1)
                 b = (b*m);
              n = n >> 1 ;
              m = (m*m);
        }
        return b;
    }
    int main()
    {
        scanf("%lld%lld%lld",&L,&R,&K);
        long long tmp1=(log(L)/log(K)+0.1);
        long long tmp2=(log(R)/log(K)+0.1);
        if(POW(K,tmp1)<L) tmp1++;
        if(POW(K,tmp2)>R) tmp2--;
        if(tmp2<tmp1) printf("-1");
        else
        {
            long long now=POW(K,tmp1);
            for(long long i=tmp1; i<=tmp2; i++)
            {
                printf("%lld",now);
                now=now*K;
                if(i<tmp2)printf(" ");
                else printf("
    ");
            }
        }
        return 0;
    }
  • 相关阅读:
    重要的环境变量
    常用的转义字符
    常用系统工作命令
    栈 队列 和 双向队列
    时间
    默认值字典
    Counter
    random
    22 内置常用模块01
    super
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5141836.html
Copyright © 2011-2022 走看看