problem

504. Base 7

solution:

class Solution {
public:
string convertToBase7(int num) {
if(num==) return "";
string ans = "";
int number = abs(num);
while(number>)
{
ans = to_string(number%) + ans;
number /= ;
}
if(num<) ans = "-" + ans;
return ans; }
};

参考

1. Leetcode_504. Base 7;

【leetcode】504. Base 7的更多相关文章

  1. 【LeetCode】504. Base 7 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 内建库 BigInteger类 逐位计算 倍数相加 ...

  2. 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java

    [LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...

  3. 【Leetcode】Pascal&#39;s Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  4. 53. Maximum Subarray【leetcode】

    53. Maximum Subarray[leetcode] Find the contiguous subarray within an array (containing at least one ...

  5. 27. Remove Element【leetcode】

    27. Remove Element[leetcode] Given an array and a value, remove all instances of that value in place ...

  6. 【刷题】【LeetCode】007-整数反转-easy

    [刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接-空 007-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位 ...

  7. 【刷题】【LeetCode】000-十大经典排序算法

    [刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接 000-十大经典排序算法

  8. 【leetcode】893. Groups of Special-Equivalent Strings

    Algorithm [leetcode]893. Groups of Special-Equivalent Strings https://leetcode.com/problems/groups-o ...

  9. 【leetcode】657. Robot Return to Origin

    Algorithm [leetcode]657. Robot Return to Origin https://leetcode.com/problems/robot-return-to-origin ...

随机推荐

  1. 微信小程序将图片数据流添加到image标签中

    原文:https://blog.csdn.net/OliveLao/article/details/78136121 ---------------------------------------- ...

  2. 系统分析与设计结对项目——WordCount

    结对项目完成WordCount 合作者:201631062507  201631062526(学号) 代码地址:https://gitee.com/WordCountMC/WordCountTeam ...

  3. Java中String为什么是不可变

    什么是不可变对象? 众所周知, 在Java中, String类是不可变的.那么到底什么是不可变的对象呢? 可以这样认为:如果一个对象,在它创建完成之后,不能再改变它的状态,那么这个对象就是不可变的.不 ...

  4. php基本语法形式

    站长新闻: 备注:目前有很多人通过李书记博客找到我,请教各种关于问题,而我这段时间是比较忙的,有时候真的是有心无力,网站更新也少了,希望大家见谅!还有很多phper希望我找下关于php相关的技术文档我 ...

  5. MySQL之text字段

    TEXT类型一般分为 TINYTEXT(255长度).TEXT(65535). MEDIUMTEXT(int最大值16M),和LONGTEXT(long最大值4G)这四种,它被用来存储非二进制字符集, ...

  6. express框架封装前戏

    一.开启一文件,这里暂且命名为aexpressclass.js 声明一个app类,用来模仿http模块中的回调函数 //var route = require('http-route'); var u ...

  7. java中VO的使用(组成复杂的实体类)

    https://blog.csdn.net/G0_hw/article/details/78326359

  8. cyk追楠神系列一(SDUT3703)

    cyk追楠神系列一 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Problem Description 众所周知,cyk ...

  9. SpringMVC配置 事务管理

    1.确保持久层配置完毕 2.pom.xml里追加spring-tx 3.application-context.xml追加 <bean id="transactionManager&q ...

  10. python 导入包

    mkdir fff dddtouch ddd/test.py ddd/__init__.py sudo vi fff/te.py写入:import syssys.path.append('../')f ...