(思维)

SW和ZK是一对令人羡慕的神仙眷侣,他们之间总是充满着甜蜜如初恋的感觉。当然,再幸福的恋爱,也难免少不了磕磕绊绊,吵闹是青春朦胧情感的调味剂。在他们恋爱的第1314天,SW买了一个蛋糕,他深情对ZK说:“I LOVE YOU 1314 !”,ZK十分感动,却又开始了自怜自艾,ZK说:“你永远想象不到我有多么爱你,比你爱我还有多3000倍!”。SW立刻就不乐意了,觉得自己的爱要更多一点。直男的脾气来了,SW说:“我爱你是你爱我的 N 倍!”ZK立刻回击:“我的爱是你的 N + 1 倍!”SW又说:“我的爱是你的 N 倍后面至少还有 K 个 0 !”ZK说:“亲爱的,你真好 !”

可是问题来了,假设ZK的爱是一个整数 N,那么最小的正整数是 N 的倍数且至少以 K 个 0 结尾的这个数是多少?

输入描述

包含一行输入两个整数 N(1 <= N <= 1000000000),K(0 <= K <= 8)。

输出描述

输出包含一个正整数,表示答案。

样例输入

10 1


10 2

样例输出

10


100

题解:一位数 * 一位数要产生一个0的方法:

          5 * 2 = 10

          2 | 4 | 6 | 8 | * 5 = x0

          1 | 3 | 7 | 9 | * 10 = x0

          是 n 的倍数,且有 k 个0 ,找到 n 末尾开始的第一个数 * 上边对应的数让其产生一个 0 ,不断统计 末尾 0 的个数,如果等于k 结束。

#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<bitset>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define eps (1e-8)
#define MAX 0x3f3f3f3f
#define u_max 1844674407370955161
#define l_max 9223372036854775807
#define i_max 2147483647
#define re register
#define pushup() tree[rt]=(tree[rt<<1],tree[rt<<1|1]);
#define nth(k,n) nth_element(a,a+k,a+n);  // 将 第K大的放在k位
#define ko() for(int i=2;i<=n;i++) s=(s+k)%i // 约瑟夫
#define ok() v.erase(unique(v.begin(),v.end()),v.end()) // 排序,离散化
#define Catalan C(2n,n)-C(2n,n-1)  (1,2,5,14,42,132,429...) // 卡特兰数
using namespace std;

inline int read(){
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' & c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

typedef long long ll;
const double pi = atan(1.)*4.;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int M=63;
const int N=1e5+5;

int total(ll n){
    int num=0;
    while(n){
        if(n%10!=0) break;
        num++;
        n/=10;
    }
    return num;
}

int C(ll n){
    while(n){
        if(n%10!=0) return n%10;
        n/=10;
    }
}

int fun(int t){
    if(t==5) return 2;
    if(t&1) return 10;
    else return 5;
}
int main(){
    ll n; int k;
    scanf("%lld %d",&n,&k);
    if(total(n)>=k){
        printf("%lld\n",n);
        return 0;
    }
    while(total(n)<k)
        n*=fun(C(n));
    printf("%lld\n",n);
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值