当前位置:网站首页>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)
边栏推荐
- QML add gradient animation during state transition
- Future源码一观-JUC系列
- C import Xls data method summary IV (upload file de duplication and database data De duplication)
- 删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
- C import Xls data method summary II (save the uploaded file to the DataTable instance object)
- Solution of cursor thickening
- ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
- Skku| autonomous handover decision of UAV Based on deep reinforcement learning
- Future source code view -juc series
- 0 basic learning C language - nixie tube dynamic scanning display
猜你喜欢
Pratique technique | analyse et solution des défaillances en ligne (Partie 1)
Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL
Future源码一观-JUC系列
51 MCU external interrupt
How to use AHAS to ensure the stability of Web services?
MySQL - use of aggregate functions and group by groups
GUI 应用:socket 网络聊天室
Mobile asynchronous sending SMS verification code solution -efficiency+redis
Windos10 reinstallation system tutorial
It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
随机推荐
Oracle database knowledge points that cannot be learned (III)
CesiumJS 2022^ 源码解读[8] - 资源封装与多线程
Function: find the sum of the elements on the main and sub diagonal of the matrix with 5 rows and 5 columns. Note that the elements where the two diagonals intersect are added only once. For example,
Stringutils and collectionutils
[dynamic programming] leetcode 53: maximum subarray sum
Future源码一观-JUC系列
Introduction to A-frame virtual reality development
How programmers find girlfriends through blind dates
查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them
MPLS experiment
MySQL -- Introduction and use of single line functions
查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
Flutter local database sqflite
Future source code view -juc series
Is Shengang securities company as safe as other securities companies
Development of user-defined navigation bar in uniapp
I don't care about you. OKR or KPI, PPT is easy for you
Oracle database knowledge points (IV)
PMP 考试常见工具与技术点总结