当前位置:网站首页>2. Wrong odometer
2. Wrong odometer
2022-07-27 01:18:00 【lzl_ 0408】
【 Problem description 】
March 8th , Xiao Ming bought a new car . But soon Xiao Ming found something wrong with the car's odometer : Each digit on the odometer does not display a number 3 And number 8, That is, directly from the numbers 2 Jump to number 4, Directly from the numbers 7 Jump to number 9. Xiao Ming wondered : What is the mileage of this car .
Now? , Xiao Ming asks you for help : According to the number displayed on the odometer , Give the actual mileage .
【 Input form 】
There are multiple sets of test data entered .
Enter a positive integer in the first line T, Indicates how many sets of test data .
In the back T That's ok , One non negative integer per line , Indicates the number displayed on the odometer , It doesn't contain numbers 3 and 8. This number does not exceed 10 position .
40% Number of test data sets T 10≤T≤ 102;
30% Number of test data sets T 102≤T≤ 103;
20% Number of test data sets T 103≤T≤ 104;
10% Number of test data sets T 104≤T≤ 105;
【 Output form 】
For each group of test data , Output an integer on one line : Real mileage .
【 The sample input 】
6 0 1 12 159 111224459 124567976
【 Sample output 】
0 1 10 103 19212007 21913077
【 Problem solving skills 】
This is an octal
Their thinking :
Bit by bit calculation
hold a Convert to octal number a
a>3&&a<8 a--;
a>8 a=a-2;
Then convert octal to decimal describe : Octal is to meet 8 Into the 1, Octal numbers use 0~7 These eight numbers are used to express a number . Method : Octal numbers from low to high ( From right to left ) Calculation , The first 0 The weight of bits is 8 Of 0 Power , The first 1 The weight of bits is 8 Of 1 Power , The first 2 The weight of bits is 8 Of 2 Power , Increase in sequence , The sum of the final results is the decimal value .
give an example : Will be octal (12)O The steps to convert to decimal are as follows :
The first 0 position 2 x 8^0 = 2;
The first 1 position 1 x 8^1 = 8;
reading , Add up the results ,2+8=10, namely (12)O=(10)D.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int k;
cin>>k;
for(int i=0;i<k;i++)
{
long int n;
cin>>n;
long int sum=0;
for(int j=0;n>0;j++)
{
int a=n%10;
if(a>3&&a<8)
a--;
if(a>8)
a=a-2;
sum=sum+a*pow(8,j);// Decimal number sum
n=n/10;
}
cout<<sum<<endl;
}
return 0;
}边栏推荐
- Keil开发环境的搭建送安装包
- Jenkins -- Basic -- 5.2 -- system configuration -- system configuration
- Cannot find a valid baseurl for repo: HDP-3.1-repo-1
- Contextcompat. Checkselfpermission() method
- 深度学习汇报(2)
- Come on: encourage college graduates to return home to start businesses and employment, and help rural revitalization
- 腾讯云直播插件MLVB如何借助这些优势成为主播直播推拉流的神助攻?
- 05 - attack and defense of phishing websites
- Are you ready for the Internet of things to revolutionize manufacturing?
- 吴恩达深度学习系列教学视频学习笔记(一)——用于二分类的logistic回归函数
猜你喜欢

Jenkins--基础--03--安装后设置向导

Jenkins--基础--5.1--系统配置--插件管理

Jenkins--基础--5.2--系统配置--系统配置

什么是数字经济,它是如何改变商业模式的?

腾讯云直播插件MLVB如何借助这些优势成为主播直播推拉流的神助攻?

Jenkins--基础--5.3--系统配置--全局安全配置

Jenkins--基础--04--安装中文插件

Li Hongyi machine learning (2021 Edition)_ P5-6: small gradient processing

Jenkins -- Basic -- 5.3 -- system configuration -- global security configuration

What are the necessary functions of short video app development?
随机推荐
Solve the problem that CUDA cannot accelerate GPU in pytoch
As 5g becomes more and more popular, what positive effects will our lives be affected
Jenkins--基础--5.3--系统配置--全局安全配置
Uni-app开发App和插件以后如何开通广告盈利:uni-AD
FaceNet
Choose RTMP or RTC protocol for mobile live broadcast
力扣刷题量300记录帖
Jenkins--基础--03--安装后设置向导
Li Hongyi machine learning (2017 Edition)_ P14: back propagation
What are the necessary functions of short video app development?
Flink1.11 intervaljoin watermark generation, state cleaning mechanism source code understanding & demo analysis
Flink1.11 SQL local run demo & local webui visual solution
李宏毅机器学习(2017版)_P13:深度学习
无重复字符的最长子串
Android——数据持久化技术(三) 数据库存储
More than live streaming: what other eye-catching functions does Tencent cloud live mlvb plug-in have besides streaming / streaming
吴恩达深度学习系列教学视频学习笔记(一)——用于二分类的logistic回归函数
Zhimi Tencent cloud live mlvb plug-in optimization tutorial: six steps to improve streaming speed + reduce live delay
大四老学长的自我批评记录
Come and help you understand the mobile Internet in a minute