- 【例36.2】 计数问题
题解
- @ 2025-11-30 12:17:32
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
freopen("count.in","r",stdin);
freopen("count.out","w",stdout);
int n,x,cnt=0;
scanf("%d %d",&n,&x);
for(int i=1;i<=n;i++){
int num=i;
do{
if(num%10==x) cnt++; // 取个位运算
num/=10; // 缩位/去个位
}while(num);
}
printf("%d",cnt);
return 0;
}
0 comments
No comments so far...
Information
- ID
- 131
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 86
- Accepted
- 28
- Uploaded By