2 条题解

  • 0
    @ 2025-1-25 20:21:59
    #include<bits/stdc++.h>
    using namespace std;
    int L,R,c,d,ans,i;
    int main(){
        cin>>L>>R;
        for(i=L;i<=R;i++){
            c=i;
            while(c!=0){
                d=c%10;
                c=c/10;
                if(d==2)ans++;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    
    • 0

      怎么连个题解也不编啊 我来编一个 #include<bits/stdc++.h> using namespace std; int main() { int L,R,sum=0,k; cin>>L>>R; for(int i=L;i<=R;i++) { k=i; while(k>0) { if(k%10==2) { sum+=1; } k=k/10; } } cout<<sum; return 0; } //自己换行,我懒得换

      • 1

      信息

      ID
      4532
      时间
      1000ms
      内存
      128MiB
      难度
      1
      标签
      (无)
      递交数
      25
      已通过
      20
      上传者