首页 > [NOIP2013]记数问题
头像 叶花永不相见
发表于 2022-02-24 20:46:19
试计算在区间1 到n 的所有整数中,数字x(0 ≤ x ≤ 9)共出现了多少次? 例如,在1到11 中,即在1、2、3、4、5、6、7、8、9、10、11 中,数字1 出现了4 次。 #include<stdio.h> int main() { int n, x; sca 展开全文
头像 刘柏
发表于 2020-10-17 14:21:03
记数问题 用 vector +count 对于这个问题 要统计0~9 出现的个数。可以分为两种情况:一,数字小于10可以直接push_back();放入vector里。 二,数字大于10首先想到的就是把数字一位一位 拆分出来 放到vector 最后统计个数。拆分个位:n=n%10;进位 :n/=10 展开全文
头像 Hanson_Zhong
发表于 2022-04-16 14:05:28
https://ac.nowcoder.com/acm/contest/19306/1002 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 试计算在区间1 到n 的所有整数中 展开全文
头像 月采琉疆
发表于 2021-02-02 16:26:32
sprintf函数的使用是把n以“%d”的格式写到str字符串数组中(还是从右至左) #include<cstdio> #include<cstring> void fun(int *num, char *str){ for(int i = 0; i < str 展开全文
头像 ros275229
发表于 2022-07-27 22:30:10
链接:https://ac.nowcoder.com/acm/problem/16538 来源:牛客网 题目描述 试计算在区间1 到n 的所有整数中,数字x(0 ≤ x ≤ 9)共出现了多少次? 例如,在1到11 中,即在1、2、3、4、5、6、7、8、9、10、11 中,数字1 出现了4 次。 输 展开全文
头像 Ghostboy
发表于 2019-09-05 20:11:52
题目描述试计算在区间1 到n 的所有整数中,数字x(0 ≤ x ≤ 9)共出现了多少次?例如,在1到11 中,即在1、2、3、4、5、6、7、8、9、10、11 中,数字1 出现了4 次。 输入描述:输入共1行,包含2个整数n、x,之间用一个空格隔开。输出描述:输出共1行,包含一个整数,表示x出现的 展开全文
头像 zzfyupup
发表于 2022-06-06 19:59:56
#include<stdio.h> int main() { int a,b; int i; int count=0; scanf("%d %d",&a,&b); for(i=1;i<=a;i++) { 展开全文
头像 Zerone·
发表于 2022-05-24 15:30:42
">int main() { int n, x, sum = 0; while (scanf("%d %d", &n, &x) != EOF) { for (int i = 1; i <= n; i++) { int te 展开全文
头像 夜语声烦-
发表于 2022-02-07 01:21:27
好吧,说实话我还以为是计数类DP,没想到完全想复杂了,不过我这是万能的,可以求任意x~y直接任意z的出现次数,用前缀和就行cnt(y,z) - cnt(x-1,z) # include <iostream> # include <cmath> using namespace 展开全文
头像 cfn
发表于 2023-03-05 17:27:39
n,x=map(int,input().split()) list1=[] for i in range(1,n+1): if str(x) in str(i): list1.append(str(i).count(str(x))) print(sum(list1))

等你来战

查看全部