Given a positive integer num, write a function which returns True if num is a perfect square else False.

Note: Do not use any built-in library function such as sqrt.

Example 1:

  1. Input: 16
  2. Output: true

Example 2:

  1. Input: 14
  2. Output: false
  1. 想法:完全平方数是等差数列相加。
  1. class Solution {
  2. public:
  3. bool isPerfectSquare(int num) {
  4. ;
  5. ){
  6. num = num - x;
  7. x = x + ;
  8. }
  9. ;
  10. }
  11. };

leetcode367--Valid Perfect Square的更多相关文章

  1. 367. Valid Perfect Square

    原题: 367. Valid Perfect Square 读题: 求一个整数是否为完全平方数,如1,4,9,16,……就是完全平方数,这题主要是运算效率问题 求解方法1:812ms class So ...

  2. Leetcode之二分法专题-367. 有效的完全平方数(Valid Perfect Square)

    Leetcode之二分法专题-367. 有效的完全平方数(Valid Perfect Square) 给定一个正整数 num,编写一个函数,如果 num 是一个完全平方数,则返回 True,否则返回 ...

  3. LeetCode_367. Valid Perfect Square

    367. Valid Perfect Square Easy Given a positive integer num, write a function which returns True if  ...

  4. [Swift]LeetCode367. 有效的完全平方数 | Valid Perfect Square

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  5. [LeetCode] Valid Perfect Square 检验完全平方数

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  6. Leetcode 367. Valid Perfect Square

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  7. Valid Perfect Square

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  8. 【leetcode】367. Valid Perfect Square

    题目描述: Given a positive integer num, write a function which returns True if num is a perfect square e ...

  9. [leetcode]367. Valid Perfect Square验证完全平方数

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  10. 367. Valid Perfect Square判断是不是完全平方数

    [抄题]: Given a positive integer num, write a function which returns True if num is a perfect square e ...

随机推荐

  1. Herding(hdu4709)三点运用行列式求面积

    Herding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  2. Codeforces675D(SummerTrainingDay06-J)

    D. Tree Construction time limit per test:2 seconds memory limit per test:256 megabytes input:standar ...

  3. POJ3090(SummerTrainingDay04-M 欧拉函数)

    Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7450   Accepted: ...

  4. [SDOI2010]猪国杀

    题面 (这个做题面的大佬太赞啦) 无聊啊~~~然后就写大模拟,然后就从早上写到下午,生活得到了极大的充实 注意事项: 牌库为空之后再抽牌,会重复抽最后一张被抽走牌 无论在任何过程中,游戏结束(主公死或 ...

  5. element-ui Message组件源码分析整理笔记(八)

    Message组件源码: main.js import Vue from 'vue'; import Main from './main.vue'; import { PopupManager } f ...

  6. CSS 简单归纳 -- 前端知识

    CSS:cascading style sheets层叠样式表,用于美化页面 css的三种表现形式:1.行内样式(内嵌样式):结构的内部,即写在标签内的样式:写在标签的开始部分内部,style属性当中 ...

  7. MyEclipse tomcat jsk配置--- jvm blind 异常

    -Xms1200m -Xmx1200m -XX:PermSize=64M-XX:MaxPermSize=256m-XX:ReservedCodeCacheSize=48m-Dcom.sun.manag ...

  8. kafka-hadoop-consumer

    写了一个工具,从kafka传输数据到hdfs,采用的api,可以消费指定的kafka topic 或者为了简便可以消费所有的topic中各个partition的数据. 地址:https://githu ...

  9. MariaDB Centos7 下安装MariaDB

    Centos7 下安装MariaDB by:授客 QQ:1033553122 1.下载安装文件 rpm包为例,对于标准服务器安装,至少需要下载client,shared,serve文件(安装时如果少了 ...

  10. .net4.0多进程间共享内存实现通信(VB.Net)

    .net4.0新增内存共享功能,从而很方便的实现了多进程间通信. 源码下载