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. 使用phpstudy搭建的外网网站 运行很慢 解决办法

    将连接数据库的配置文件 localhost  修改为127.0.0.1 PHP5.3以上,如果是链接localhost,会检测是IPV4还是IPV6,所以会比较慢.解决办法是:链接数据的时候,不要填写 ...

  2. React 新特性学习

    1 context 2 contextType 3 lazy 4 suspense 5 memo 6 hooks 7 effect hooks =========== 1 Context 提供了一种方 ...

  3. [转载]深入理解Java垃圾回收机制

    深入理解Java垃圾回收机制 2016-07-28 20:07:49 湖冰2019 阅读数 14607更多 分类专栏: JAVA基础   原文:http://www.linuxidc.com/Linu ...

  4. ip_srcroute函数

    当响应某个分组时,I C M P和标准的运输层协议必须把分组带的任意源路由逆转.逆转源路由是通过i p _ s r c r o u t e保存的路由构造的. 7 7 7 - 7 8 3 i p _ s ...

  5. C# 通过浏览器打开指定url

    using System.Diagnostics; var resultsg = Process.Start(@"C:\Users\Administrator\AppData\Local\S ...

  6. 团队开发前端VUE项目代码规范

    团队开发前端VUE项目代码规范 2018年09月22日 20:18:11 我的小英短 阅读数 1658   一.规范目的: 统一编码风格,命名规范,注释要求,在团队协作中输出可读性强,易维护,风格一致 ...

  7. Codevs 1242 布局 2005年USACO(差分约束)

    1242 布局 2005年USACO 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 当排队等候喂食时,奶牛喜欢和它们的朋友站得靠近 ...

  8. 关于lda算法的一个博客

    http://www.cnblogs.com/LeftNotEasy/archive/2011/01/08/lda-and-pca-machine-learning.html

  9. devstack cinder-volume服务状态为down

    cinder-manage service list 查看到有一个 xxx状态 Binary Host Zone Status State Updated At RPC Version Object ...

  10. 学习ArrayList的扩容机制

    基于jdk8 1.首先我们看new ArrayList中 public ArrayList() { this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDA ...