2 条题解

  • 3
    @ 2022-7-3 22:51:24

    一个水题

    #include<iostream>
    using namespace std;
    int main(){
    	int n,x,ans=0;
    	cin>>n>>x;
    	for(int i=1;i<=n;i++){
    		int tmp=i,num;
    		while(tmp!=0){
    			num=tmp%10;
    			if(num==x){
    				ans++;
    			}
    			tmp/=10;
    		}
    	}
    	cout<<ans<<endl;
    }
    

    https://www.luogu.com.cn/record/78159837

    本人完隐,看不到记录。

    • 2
      @ 2023-9-30 11:24:14
      #include<iostream>
      #include<cmath>
      #include<algorithm>
      #include<cstdio>
      #include<string>
      #include<cstring>
      using namespace std;
      int n,x;
      int res=0;
      int main(){
      	//freopen("count.in","r",stdin);
      	//freopen("count.out","w",stdout);
      	int tmp,tmp1;
      	scanf("%d %d",&n,&x);
      	for(int i=1;i<=n;i++){
      		tmp=i;
      		while(tmp!=0){
      			tmp1 = tmp%10;
      			if(tmp1==x){
      				res+=1;
      			}
      			tmp/=10;
      		} 
      	}
      	cout << res;
      	//fclose(stdin);
      	//fclose(stdout);
      	return 0;
      }
      
      • 1

      信息

      ID
      943
      时间
      1000ms
      内存
      125MiB
      难度
      1
      标签
      递交数
      228
      已通过
      135
      上传者