当前位置:网站首页>AcWing 1912. Odometer (enumeration)
AcWing 1912. Odometer (enumeration)
2022-06-12 10:55:00 【Eurya song】
【 Title Description 】
John's cow is traveling on the road .
The odometer on their car shows the whole mileage .
At the beginning of the journey, the mileage displayed on the odometer is X X X, At the end of the trip, the mileage displayed on the odometer is Y Y Y.
Whenever the odometer shows “ amusing ” Numbers ( Including the numbers displayed at the beginning and end ) when , The cows will make a pleasant cry .
If a number is in all numbers except the leading zero , Except for a different number , All other numbers are the same , So this number is “ amusing ”.
for example ,33323 and 110 It's interesting. , and 9779 and 55555 Not interesting .
Please help John count the number of times the cows cry during the journey .
【 Input format 】
All in one line , Contains two integers X X X and Y Y Y.
【 Output format 】
Output the number of times the cows make calls during the journey .
【 Data range 】
100 ≤ X ≤ Y ≤ 1 0 16 100≤X≤Y≤10^{16} 100≤X≤Y≤1016
【 sample input 】
110 133
【 sample output 】
13
【 Sample explanation 】
110 ∼ 133 110\sim 133 110∼133 Of all the numbers between , Interesting numbers are :
110 , 112 , 113 , 114 , 115 , 116 , 117 , 118 , 119 , 121 , 122 , 131 , 133 110,112,113,114,115,116,117,118,119,121,122,131,133 110,112,113,114,115,116,117,118,119,121,122,131,133.
【 analysis 】
Observing this data range, we cannot enumerate X ∼ Y X\sim Y X∼Y And then determine whether it is an interesting number , So we need to change the angle , You can enumerate all the interesting numbers , That is, the number of digits to be satisfied is 3 ∼ 17 3\sim 17 3∼17 There is only one digit difference , Other figures are the same . For every interesting number of enumerations , If in X ∼ Y X\sim Y X∼Y In the range of , Add one to the answer .
【 Code 】
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL x, y;
int res;
int main()
{
cin >> x >> y;
for (int i = 3; i <= 17; i++)// Enumerator bits
for (int j = 0; j < 10; j++)// Enumerate which number is the same
for (int k = 0; k < 10; k++)// Enumerate the only different number
if (j != k)// The two numbers must be different
for (int u = 0; u < i; u++)// Enumerate where different numbers appear
{
string str(i, '0' + j);
str[u] = '0' + k;
if (str[0] != '0')// There can't be leading zeros
{
LL num = stoll(str);
if (num >= x && num <= y) res++;
}
}
cout << res << endl;
return 0;
}
边栏推荐
- Solution to the problem that the applet developer tool cannot input simplified Chinese
- How to upload the video on the computer to the mobile phone without network
- Building 64 bit wampserver and DVWA in win7 virtual machine
- AcWing 1912. 里程表(枚举)
- Malicious code analysis practice - use IDA pro to analyze lab05-01 dll
- AcWing 1995. 见面与问候(模拟)
- Reverse analysis of Huawei housekeeper software [transfer]
- Common configuration commands for Cisco network device security management
- 命名规范/注释规范/逻辑规范
- PHP Apple internal purchase callback processing
猜你喜欢

SOT23(Small Outline Transistor)

AcWing 128. 编辑器(对顶栈 实现序列内部指定位置高效修改)

k58.第一章 基于kubeadm安装kubernetes v1.23 -- 集群部署

Bug easily ignored by recursion

Machine learning is not something you can use if you want to use it

B+ 树的简单认识

淺談調和形狀上下文特征HSC對3DSC的改進

M-Arch(番外11)GD32L233评测-PWM驱动有源蜂鸣器

How the ArrayList collection implements ascending and descending order

Malicious code analysis practice -- using apatedns and inetsim to simulate network environment
随机推荐
Assign a specified amount to a specified number of people at random
AcWing 1986. 镜子(模拟,环图)
Pseudo static setting of access database in win2008 R2 iis7.5
JS open common application market
Binassii module - converting between binary and ASCII
使用cpolar远程办公(2)
Several methods of importing ThinkPHP
Get start date and end date for all quarters of the year
How to play the 618 super cat games on Taobao? Here comes the introduction to the overall activities of the Super Cat Games
FPGA开发——Hello_world例程
Common regular expressions
Leetcode 2169. 得到 0 的操作数
AcWing 41. Stack containing min function (monotone stack)
Solution to invalid small program scroll into view
浅谈调和形状上下文特征HSC对3DSC的改进
Building 64 bit wampserver and DVWA in win7 virtual machine
Valentina Studio Pro for MAC (MAC database management software)
Machine learning is not something you can use if you want to use it
InfoQ geek media's 15th anniversary solicitation |position:fixed virtual button cannot take effect after being triggered. Problem analysis and Solution Exploration
How to play the 2022 Taobao 618 Super Cat Games? Playing skills of 2022 Taobao 618 Cat Games