码迷,mamicode.com
首页 > 编程语言 > 详细

杭电oj2089c++

时间:2020-03-10 21:58:35      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:mamicode   mic   name   while   out   stream   include   技术   space   

技术图片

 

 本题如果将int型转化为字符串,则会显示超时,所以只能用从后往前一位一位的判断是否含有4或者62

#include <iostream>
#include<string>
using namespace std; 
int main() {
    int m,n;
    int index;
    bool flag;
    int x;
    while(cin>>n>>m)
    {
        if(n==0&&m==0)
        {
            break;
        }
        index=0;
        for(int i=n;i<=m;i++)
        {
            x=i;
            while(x!=0)
            {
                
                //判断是否含有4 
                if((x%10)==4||(x%100)==62)
                {
                    index++;
                    break;
                }
                x=x/10;    
            }
        
        }
        cout<<m-n-index+1<<endl; 
    }
    return 0;
}

 

杭电oj2089c++

标签:mamicode   mic   name   while   out   stream   include   技术   space   

原文地址:https://www.cnblogs.com/ljysy/p/12458536.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!