214 条题解
-
21
赵震昊 LV 6 @ 6 年前
-
148 年前@
#include <stdio.h>
int main()
{
int i,n,x,k=0,j;
scanf("%d %d",&n,&x);
for(i=1;i<=n;i++)
{
j=i;
while(j)
{
if(j%10==x)
k++;
j=j/10;}
}
printf("%d",k);
return 0;
} -
85 年前@
还是先分析思路:
1. 输入数据,终止点和查找字符
2. for循环判断1. 定义临时判断数据temp,将它的值设为控制器i的值
2. while循环1. 条件:temp > 0(原因后面再说)
2. 如果temp的末位是x,则ans++,然后temp去掉末位继续判断(原因知道了吧)
3.输出ans这题比较简单,稍微有些基础的人就可以做出来
祝大家AC!
点赞吧! -
64 年前@
数位dp写法,全部1ms
-
33 年前@
- 输入
- 遍历 ~
- 分解枚举到的数,求出每一位
- 依次判断是否与 相等
分解代码:
完整代码:
完美 ,撒花!
-
33 年前@
//字符串也行
#include<iostream>
using namespace std;
#include<string>
void test106()
{
int n;
int x;
cin >> n >> x;
int count = 0;
for (int i = 1; i <= n; i++)
{
string f = to_string(i);
for (int i = 0; i < f.size(); i++)
{
if ((f[i]-'0') == x)
count++;}
}
cout << count << endl;
}
int main()
{
test106();
} -
33 年前@
-
34 年前@
暴力出奇迹
-
23 年前@
-
24 年前@
我永远爱CSDN
https://blog.csdn.net/beguile/article/details/103635707 学的函数
Python 永远的神
三行哈哈哈哈所以python永远的神(bushi)
暴力(会超时) -
19 个月前@
点个赞再走呗。
-
110 个月前@
AC代码
思路分析:
作为本人的第一篇题解,还是有点小激动的>_<
1.输入数据
2.数位分离+遍历 1-n (可以用 for 实现)
3.累计答案 ANSCode
cin,cout 版如果想再快一点,可以使用 scanf,printf 等函数,这里就不给出代码啦
最后,分享一个链接,有兴趣的可以学学:快读快写(炸裂版)
祝各位 RP++,AK NOI!
Powered By 一个努力进步的蒟蒻
2024.7.23晚 -
11 年前@
qwq
-
11 年前@
-
02 个月前@
-
01 年前@
-
01 年前@
n, x = input().split(' ')
count = 0for i in range(1, int(n)+1):
count += str(i).count(x)
print(count) -
02 年前@
难度不大。
核心代码:完整代码:
-
02 年前@
-
02 年前@
#include<iostream>
using namespace std;
int main(){
int n,x,sum=0;
int p;
cin>>n>>x;
for(int i=1;i<=n;i++){
p=i;
while(p>0){
if(p%10==x){
sum++;
}
p=p/10;
}
}
cout<<sum;
}
信息
- ID
- 1848
- 难度
- 5
- 分类
- (无)
- 标签
- 递交数
- 16655
- 已通过
- 5836
- 通过率
- 35%
- 被复制
- 37
- 上传者