文章
2
粉丝
0
获赞
9
访问
986
具体代码如下,想着写一个数组模拟进制转换的万用方法,算法复杂度应该是O(n^2),不理解为什么会导致超时,用于提交其他题目也是能成功通过的,个人初步推断是有特殊情况的用例没有考虑到导致bug才引起的超时,但实在找不到是哪种情况,麻烦大佬们给给意见,谢谢!
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
using namespace std;
char radixForm(int num){
return num<10?num+'0':(num-10)+'a';
}
int radixForm(char ch){
if(ch>='a'){
ch=ch-'a'+'A';
}
return ch<='9'?ch-'0':ch-'A'+10;
}
string legalizedNumStr(string s,int radix){
while(s[0]=='0'&&...
登录后发布评论
修改后的代码