当前位置:网站首页>OJ 1284 counting problem
OJ 1284 counting problem
2022-07-28 06:38:00 【JETECHO】
describe
Try to calculate in the interval 1 To n Of all integers , Numbers x(0≤x≤9) How many times have there been ? for example , stay 1 To 11 in , That is to say 1、2、3、4、5、6、7、8、9、10、11 in , Numbers 1 There is 4 Time .
Input
Each group of input data has a total of 1 That's ok , contain 2 It's an integer n、x, Separated by a space .
Data scale :
about 100% The data of ,1≤n≤1,000,000,0≤x≤9.
Output
Total output per group 1 That's ok , Contains an integer , Express x Number of occurrences .
sample input 1
11 1
sample output 1
4
The question requires finding out the number of times the number appears , You can use loops , from 1 To n Check , adopt Remainder 10 And divided by 10 To get every bit , To determine whether it is x
#include <iostream>
#include <string>
using namespace std;
int main()
{
long long x,n;
while(cin>>x>>n)
{
int cont=0;
for(int i=1;i<=x;i++)
{
int k=i;
while(k)
{
if(k%10==n)
cont++;
k/=10;
}
}
cout<<cont<<endl;
}
return 0;
}
边栏推荐
- QT implementation outputs relevant information to log file
- OJ 1045 reverse and add
- 开放式耳机有哪些、四款音质超好的气传导耳机推荐
- MFC uses the console to print program information
- Icc2 (IV) routing and postroute optimization
- 【动态规划--买卖股票的最佳时期系列3】
- Icc2 (III) clock tree synthesis
- What is hash? (development of Quantitative Trading Robot System)
- 小程序:生命周期
- [队列,栈的简单应用----包装机]
猜你喜欢

Use and safe shutdown of qthread thread in QT

Development of clip arbitrage / brick carrying arbitrage system

QT implementation outputs relevant information to log file

C语言的编译和预处理

什么气传导蓝牙耳机好、配置比较高的气传导耳机推荐

Problems of font modification and line spacing in word automatic directory

七夕送女朋友什么礼物好?不会送礼的男生速看!

Leetcode 刷题日记 剑指 Offer II 053. 二叉搜索树中的中序后继

What's a good gift for your girlfriend on the Chinese Valentine's day in 2022? Practical and beautiful gift recommendation

雨伞上的水滴效果
随机推荐
2022-06-07 ResponseBodyAdvice导致Swagger出现弹框问题
Icc2 use report_ Placement check floorplan
空气传导耳机哪个牌子好、备受好评的气传导耳机推荐
关于时间复杂度,你不知道的都在这里
OJ 1242 freshman's debut
What are the open earphones? Four types of air conduction earphones with excellent sound quality are recommended
OJ 1020 最小的回文数
QT solves the problem of rebuilding UI files every time they are modified
[c语言]简易通讯录的实现
Leetcode 刷题日记 剑指 Offer II 048. 序列化与反序列化二叉树
Get the current directory in QT
七夕礼物送女生什么好?颜值在线又有心意的礼物推荐
自定义组件--数据监听器
What's a good gift for your girlfriend on the Chinese Valentine's day in 2022? Practical and beautiful gift recommendation
[哈希表基础知识]
OpenGL quick configuration method
ZOJ Problem 1005 jugs
气传导蓝牙耳机什么牌子好、气传导耳机最好的品牌推荐
动态规划--多步爬楼梯(爬楼梯进阶版)
OJ 1451 数字游戏