当前位置:网站首页>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)
边栏推荐
- I don't care about you. OKR or KPI, PPT is easy for you
- Related configuration commands of Huawei rip
- File contains vulnerability summary
- Functions and arrays of shell scripts
- SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution
- Future source code view -juc series
- Skku| autonomous handover decision of UAV Based on deep reinforcement learning
- Summary of JWT related knowledge
- Print diamond pattern
- Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL
猜你喜欢
Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL
查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
MySQL deadly serial question 2 -- are you familiar with MySQL index?
Huawei BFD and NQA
机器学习基础:用 Lasso 做特征选择
Function: store the strings entered in the main function in reverse order. For example, if you input the string "ABCDEFG", you should output "gfedcba".
AI helps make new breakthroughs in art design plagiarism retrieval! Professor Liu Fang's team paper was employed by ACM mm, a multimedia top-level conference
Luogu p1309 Swiss wheel
功能:求出菲波那契数列的前一项与后一项之比的极限的 近似值。例如:当误差为0.0001时,函数值为0.618056。
be based on. NETCORE development blog project starblog - (14) realize theme switching function
随机推荐
Function: store the strings entered in the main function in reverse order. For example, if you input the string "ABCDEFG", you should output "gfedcba".
Is Shengang securities company as safe as other securities companies
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).
Special copy UML notes
Network layer - routing
机器学习基础:用 Lasso 做特征选择
关于 uintptr_t和intptr_t 类型
Flutter local database sqflite
About uintptr_ T and IntPtr_ T type
7.1 learning content
Msp32c3 board connection MSSQL method
Hbuilder link Xiaoyao simulator
Three layer switching ①
GUI 应用:socket 网络聊天室
leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
Luogu p1309 Swiss wheel
be based on. NETCORE development blog project starblog - (14) realize theme switching function
swagger中响应参数为Boolean或是integer如何设置响应描述信息
AI 助力艺术设计抄袭检索新突破!刘芳教授团队论文被多媒体顶级会议ACM MM录用
Future源码一观-JUC系列