#32679: ans


yp11151049@yphs.tp.edu.tw (801-24)

學校 : 臺北市私立延平高級中學
編號 : 197224
來源 : [203.72.178.1]
最後登入時間 :
2024-01-16 09:26:24
d899. NOIP2010 1.数字统计 -- NOIP2010普及组第一题 | From: [203.72.178.1] | 發表日期 : 2022-10-26 17:09

#include<bits/stdc++.h>
using namespace std;
int main(){
    int l,r;
    while(cin>>l>>r){
        int c=0;
        for(int i=l;i<=r;i++){
            int temp=i;
            while(temp!=0){
                if(temp%10==2) c++;
                temp/=10;
            }
        }
        cout<<c<<endl;
    }
    return 0;
}

 
ZeroJudge Forum