1、题目描述

2、代码

 int rotatedDigits(int N) {
int res = ; for (int i = ; i <= N; i++) {
if (isGood(i)) {
res++;
}
} return res;
} bool isGood(int x)
{
int rx = x;
vector<int> nums;
while (x) {
int r = x % ;
nums.push_back(r);
x = x / ;
} for (vector<int>::iterator it = nums.begin(); it != nums.end(); it++ ) {
if (*it == || *it == || *it == )
return false;
if (*it == || *it == || *it == )
continue; if (*it == ) {
*it = ;
continue;
} if (*it == ) {
*it = ;
continue;
} if (*it == ) {
*it = ;
continue;
} if (*it == ) {
*it = ;
continue;
}
} int good = ;
for (vector<int>::reverse_iterator ite = nums.rbegin(); ite != nums.rend(); ite++) {
good = good * + *ite;
} return good != rx;
}

LeetCode题解之Rotated Digits的更多相关文章

  1. LeetCode算法题-Rotated Digits(Java实现)

    这是悦乐书的第316次更新,第337篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第185题(顺位题号是788).如果一个数字经过180度旋转后,变成了一个与原数字不同的 ...

  2. 【LeetCode】788. Rotated Digits 解题报告(Python)

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

  3. LeetCode 题解之Add Digits

    1.问题描述 2.问题分析 循环拆分数字,然求和判断. 3.代码 int addDigits(int num) { ) return num; int result = num; do{ vector ...

  4. 73th LeetCode Weekly Contest Rotated Digits

    X is a good number if after rotating each digit individually by 180 degrees, we get a valid number t ...

  5. [LeetCode 题解] Search in Rotated Sorted Array

    前言 [LeetCode 题解]系列传送门: http://www.cnblogs.com/double-win/category/573499.html 题目描述 Suppose an array ...

  6. LeetCode 788. 旋转数字(Rotated Digits) 36

    788. 旋转数字 788. Rotated Digits 题目描述 我们称一个数 X 为好数, 如果它的每位数字逐个地被旋转 180 度后,我们仍可以得到一个有效的,且和 X 不同的数.要求每位数字 ...

  7. [LeetCode 题解]:Palindrome Number

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Determine ...

  8. [LeetCode 题解]:Intersection of Two Linked Lists

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Suppose an ...

  9. [LeetCode 题解]: plusOne

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Given a no ...

随机推荐

  1. Redis+Jedis封装工具类

    package com.liying.monkey.core.util; import java.io.IOException; import java.util.ArrayList; import ...

  2. spec 文件详解

    转自http://blog.sina.com.cn/s/blog_43b39e250100nnu4.html rpm软件包系统的标准分组:/usr/share/doc/rpm-4.3.3/GROUPS ...

  3. ELK之filebeat

    1.概述 filebeat使用go语言开发,轻量级.高效.主要由两个组件构成:prospector和harvesters. Harvesters负责进行单个文件的内容收集,在运行过程中,每一个Harv ...

  4. vue项目webpack打包后图片路径错误

    首先项目是vue-cli搭建的,项目结构如下: 然后发现在css里写的图片引用地址在开发时正常显示,但在打包扔上服务器之后报错 报的是404,路径前面多了/static/css,不知道为啥. 在自己慢 ...

  5. async、await正确姿势

    摘要 async.await是在C# 5.0之后引入的一种简化异步操作的方式.使用它们之后,可以使我们的编写异步操作更加方便快捷,维护以及阅读起来更方便. 一个例子 async.await虽然简化了我 ...

  6. Lucene 学习-安装 Elasticsearch 服务器

    全文搜索属于最常见的需求,开源的 Elasticsearch 是目前全文搜索引擎的首选,它的底层是开源库 Lucene.但是我们没法直接使用 Lucene,必须自己写代码去调用它的接口. Elasti ...

  7. hdu 1568 (log取对数 / Fib数通项公式)

    hdu 1568 (log取对数 / Fib数通项公式) 2007年到来了.经过2006年一年的修炼,数学神童zouyu终于把0到100000000的Fibonacci数列 (f[0]=0,f[1]= ...

  8. MySQL,Oracle建立主键自增表

    MySQL 在建表的时候声明字段即可 id int auto_increment primary key not null Oracle 第一步:建立表 drop table t_role; crea ...

  9. JDBC流程

    最近要学习Mybatis的源码,因此对JDBC的使用进行总结. 一.JDBC概述 JDBC(Java DataBase Connectivity,java数据库连接)是一种用于执行SQL语句的Java ...

  10. php pdo对象使用详解: 连接数据库与exec方法

    要使用pdo,首先需要开启pdo扩展,我这里已经开启了mysql的pdo扩展 ghostwu@dev:~$ php -m | grep pdo pdo_mysql ghostwu@dev:~$ 1,连 ...