当前位置:网站首页>LeetCode 168. Detailed explanation of Excel list name
LeetCode 168. Detailed explanation of Excel list name
2022-07-04 01:27:00 【Vogelbaum】
I got to this simple difficult problem
At first glance, it's a hexadecimal conversion problem, but it's easy to fall into the pit .
First of all, let's talk about binary conversion ,
With 701 For example , This number can be converted into the following form :
1-26 Represent the A-Z, Use chr(65+x) You can easily convert numbers into symbols ,
But the question here is very stupid B The place is already obvious :
With simple division, you will only get 0, Can't get 26, Although it can also be judged by conditions, this formula can be converted into
Divide by each cycle 26, The number you get -1 Then divide the remainder to ensure that the number obtained is 0-25, Represent the A-Z
num = 701
string = ''
while num:
num -= 1
val = num%26
num -= val
num = int(num/26)
print(val)
string = chr(65+val) + string
print(string)
边栏推荐
- Sequence list and linked list
- 7.1 学习内容
- MySQL deadly serial question 2 -- are you familiar with MySQL index?
- Mongodb learning notes: command line tools
- How to use AHAS to ensure the stability of Web services?
- Meta metauniverse female safety problems occur frequently, how to solve the relevant problems in the metauniverse?
- How to set the response description information when the response parameter in swagger is Boolean or integer
- leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
- Long article review: entropy, free energy, symmetry and dynamics in the brain
- How to use AHAS to ensure the stability of Web services?
猜你喜欢
Make drop-down menu
How to delete MySQL components using xshell7?
基于.NetCore开发博客项目 StarBlog - (14) 实现主题切换功能
Function: find the approximate value of the limit of the ratio of the former term to the latter term of Fibonacci sequence. For example, when the error is 0.0001, the function value is 0.618056.
Employees' turnover intention is under the control of the company. After the dispute, the monitoring system developer quietly removed the relevant services
C import Xls data method summary II (save the uploaded file to the DataTable instance object)
Network layer - routing
SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution
Function: store the strings entered in the main function in reverse order. For example, if you input the string "ABCDEFG", you should output "gfedcba".
Luogu p1309 Swiss wheel
随机推荐
7.1 learning content
功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
1-redis architecture design to use scenarios - four deployment and operation modes (Part 1)
Oracle database knowledge points that cannot be learned (II)
Cesiumjs 2022^ source code interpretation [8] - resource encapsulation and multithreading
Day05 table
A little understanding of GSLB (global server load balance) technology
Customize redistemplate tool class
SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution
0 basic learning C language - nixie tube dynamic scanning display
Day05 表格
Leetcode 121 best time to buy and sell stock (simple)
51 MCU external interrupt
Since the "epidemic", we have adhered to the "no closing" of data middle office services
be based on. NETCORE development blog project starblog - (14) realize theme switching function
基于.NetCore开发博客项目 StarBlog - (14) 实现主题切换功能
Oracle database knowledge points that cannot be learned (III)
Openbionics exoskeleton project introduction | bciduino community finishing
GUI application: socket network chat room
Function: write function fun to find s=1^k+2^k +3^k ++ The value of n^k, (the cumulative sum of the K power of 1 to the K power of n).