全部评论
蹲个大佬ak代码
太难了吧,***了
https://blog.csdn.net/weixin_43939593/article/details/120337476 二叉树右移
https://www.nowcoder.com/discuss/747270 第二题,取反,ak,python
为何要为难我一个测开😪
#include <bits/stdc++.h> using namespace std; class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param n int整型 * @param k int整型 * @return long长整型 */ long long minM(int n, int k) { // write code here // n 表示1出现的此树,k 表示进制数 long long num = 0; long long times = 0; int t; while(times < n) { num++; if(num % k < k && num % k > 1) { times += t-1; }else { t = number(num, k); times += t; } } cout << num << endl; return num; } private: long long number(long long num, int k) { int count = 0; while(num != 0) { int i = num % k; if(i == 1) count++; num /= k; } return count; } }; int main() { Solution sol; sol.minM(10, 10); } 超时 a了0.682,还可以咋优化??大佬解个惑
相关推荐
02-16 12:56
门头沟学院 嵌入式软件开发 点赞 评论 收藏
分享