problem

970. Powerful Integers

solution:

class Solution {
public:
vector<int> powerfulIntegers(int x, int y, int bound) {
unordered_set<int> tmp;
for(int a=; a<bound; a*=x)//
{
for(int b=; a+b<=bound; b*=y)
{
tmp.insert(a+b);//
if(y==) break;//
}
if(x==) break;
}
return vector<int>(tmp.begin(), tmp.end());
} };

参考

1. Leetcode_easy_970. Powerful Integers;

【Leetcode_easy】970. Powerful Integers的更多相关文章

  1. 【leetcode】970. Powerful Integers

    题目如下: Given two non-negative integers x and y, an integer is powerful if it is equal to x^i + y^j fo ...

  2. 【LeetCode】970. Powerful Integers 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 暴力搜索 日期 题目地址:https://leetc ...

  3. LeetCode 970. Powerful Integers (强整数)

    题目标签:HashMap 题目让我们找出所有独一的powerful integers 小于bound的情况下. 把 x^i 看作 a:把 y^j 看作b, 代入for loop,把所有的情况都遍历一遍 ...

  4. LC 970. Powerful Integers

    Given two non-negative integers x and y, an integer is powerful if it is equal to x^i + y^j for some ...

  5. 【leetcode】Divide Two Integers (middle)☆

    Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...

  6. 【Leetcode】【Medium】Divide Two Integers

    Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...

  7. 【Leetcode】Divide Two Integers

    Divide two integers without using multiplication, division and mod operator. class Solution { public ...

  8. 【Leetcode】 - Divide Two Integers 位运算实现整数除法

    实现两个整数的除法,不许用乘法.除法和求模.题目被贴上了BinarySearch,但我没理解为什么会和BinarySearch有关系.我想的方法也和BS一点关系都没有. 很早以前我就猜想,整数的乘法是 ...

  9. Leetcode 970. Powerful Integers

    Brute Force(暴力) class Solution(object): def powerfulIntegers(self, x, y, bound): """ ...

随机推荐

  1. 洛谷 P1032 字串变换 题解

    每日一题 day19 打卡 Analysis 广搜+map判重 用find寻找字串,再用replace替换字串 这里的map相当于正常广搜的一个book的作用 #include<iostream ...

  2. Kafka 通过python简单的生产消费实现

    使用CentOS6.5.python3.6.kafkaScala 2.10  - kafka_2.10-0.8.2.2.tgz (asc, md5) 一.下载kafka 下载地址 https://ka ...

  3. java大文件分块上传断点续传demo

    第一点:Java代码实现文件上传 FormFile file = manform.getFile(); String newfileName = null; String newpathname =  ...

  4. codevs:1313 质因数分解:已知正整数 n是两个不同的质数的乘积,试求出较大的那个质数 。

    #include<iostream>#include<cstdio>#include<cmath>using namespace std;int a[2];int ...

  5. Random Target Moving~

    测试了一下用向量处理随机目标,还是挺有趣的,源码如下: PVector p1, p2; float gap = 10; void setup() { size(1920, 1080); backgro ...

  6. SpringCloud:搭建微服务项目框架 microservicecloud

    1.搭建整体父工程 microservicecloud 新建父工程microservicecloud,切记是Packageing是pom模式 主要是定义POM文件,将后续各个子模块公用的jar包等统一 ...

  7. Linux 修改时区的办法

    Linux修改时区的正确方法 CentOS和Ubuntu的时区文件是/etc/localtime,但是在CentOS7以后localtime以及变成了一个链接文件 [root@centos7 ~]# ...

  8. Latex 数字加粗后变宽 Latex bold without increasing the length of the text

    Add the following code at the beginning of the article \newsavebox\CBox \def\textBF#1{\sbox\CBox{#1} ...

  9. zabbix代理

    一.概述 zabbix proxy可以代替zabbix server检索客户端的数据,然后把数据汇报给zabbix server,并且在一定程度上分担了zabbix server的压力.zabbix ...

  10. 【软工实践】团队Git现场编程实战

    组长博客链接 博客链接 组员职责分工 队员 职责分工 恩泽 进行任务的划分与安排,调用API,负责餐饮商铺及商圈信息的获取 金海 解析API返回的json数据,提取有关信息 君曦 部分算法编写 季城 ...