zoukankan      html  css  js  c++  java
  • Tom and Zeros

    Description

     

    Tom is the most handsome CCPC contestant in HIT.Tom likes Zero. For a given positive integer n, he wants to know the minimum non_negativeinteger which is divisible by n and ends with k or more zeros. For example, if n is 75 and k is 4, theresult is 75*400 = 30000.

    Input

     

    The first line contains an integer T(0<=T<=100) which means T test cases.Each test case contains two integers n and k.1<=n<=1e9 , 0<=k<=8.

    Output

     

    For each test case, print one line with the answer

    Sample Input 1 

    2
    75 4
    10000 1

    Sample Output 1

    30000
    10

    该题就是求最小公倍数;
    #include<iostream>
    using namespace std;
    long long gcd(long a,long b)
    {
    long long c;
    while(b>0)
    {
    c=a%b;
    a=b;
    b=c;
    }
    return a;
    }
    long long cheng(long long k)
    {
    long long sum=1;
    while(k--)
    {
    sum*=10;
    }
    return sum;
    }
    int main()
    {
    long long t,n,k,m;
    cin>>t;
    while(t--)
    {
    cin>>n>>k;
    k=cheng(k);
    m=(n*k)/gcd(n,k);
    cout<<m<<endl;
    }
    return 0;
    }
  • 相关阅读:
    ConcurrentHashMap 实现缓存类
    maven 时区设置&ip&jdk编译版本
    【Hutool】工具类之日期时间工具-DateUtil
    正则表达式
    kafka connector
    kafka
    debezium、kafka connector 解析 mysql binlog 到 kafak
    网络流
    斜率优化
    8.8
  • 原文地址:https://www.cnblogs.com/ylrwj/p/10746640.html
Copyright © 2011-2022 走看看