楼层编号

题目描述


【问题描述】
小林在 NOIP 比赛期间住在“新世界”酒店。和其他酒店不一样的是,这个酒店每天都有一个高能的数字 t,这个数字在楼层中是不会出现的,以 t=3 为例,则 3、13、31、33 等楼层是不存在的,楼层编号为 1,2,4,5,…所以实际上的 4 楼才是 3 楼。

已知小林预订了编号为 m 层的房间,并且当天高能数字是 t,现在他想知道房间所在的真实楼层是多少。

【输入格式】
一行两个整数 m 和 t,1≤m≤100000,0≤t≤9,保证 m 对 t 合法。
【输出格式】
一行一个整数,表示真实楼层。

输入

 

输出

 

样例输入

14 3

样例输出

12

提示

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int isgo(int x,int t){
    while(x){
        if(x%10==t) return 1;
        x=x/10;
    }
    return 0;
}
int main()
{
    int m,t;
    cin>>m>>t;
    int ans=0;
    int s=0;
    for(int i=1;i<=m;i++)
    {
        if(isgo(i,t)) ans++;
    }
    cout<<m-ans;
    return 0;
}
原文地址:https://www.cnblogs.com/caiyishuai/p/10535305.html