examination questions
Write an algorithm to determine if a number is "happy".
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.
Example: 19 is a happy number
- 12 + 92 = 82
- 82 + 22 = 68
- 62 + 82 = 100
- 12 + 02 + 02 = 1
Please use the following function to solve the problem:
bool isHappy(int n) {
}
解题代码
#include <stdio.h> bool isHappy(int n) {
int arr[];
int i = ;
int sum = ;
int temp1,temp2; while (true){
do{
temp1 = n / ;
temp2 = n % ;
n = temp1;
sum = sum + temp2 * temp2;
} while (temp1 > ); if (sum != ){
arr[i] = sum;
n = sum;
i++;
}
else{
return true;
}
for (int j = ; j < i; j++){
if (sum == arr[j-]){
return false;
}
}
sum = ;
}
} int main(){
int n;
scanf("%d",&n);
if (isHappy(n)){
printf("true\n");
}
else{
printf("false\n");
}
return ;
}
LeetCode判断结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABHkAAACRCAIAAADYVvNzAAAVhUlEQVR4nO3dz4sc14EH8P2f6tSMBjEXBds4IGNW0MrBAkOQfRCLhDy24zEWG2yQDoZJjFkLedCCWKMIpNU6EA9IDEpYLJBFGGIQ2BmZxaDD3ObSl6H3UNXdr35Xt950WzOfD4G4q6vee1XVgved9+rVvwwBAACI7V8W3QAAAIBDSNYCAACIT9YCAACIT9YCAACIT9Y68vb29hbdBAAAOHxastbe9t31986cPLHcS5IkSZKllZf6Zy9ff/DDrN3zOxeSJEleX//7jMd38ff115MkSS7ceUHK7VJpSW/5xMkz763f3X6eoLS3ffP915ZmOqHijZzHjQUAgBdIQ9YaPPrs9FJlPz9JkpU3rz0azFCfrDVbpfWWTl/Z+nnGwtO7IWsBAEB8tVlr9+vVlTRUXbn78KfdLFftPdt+cH31170kSZKV1a93p65Pl3xKadYqXbDB7k/bD66//9pSkiRJ79T6TMH3ebJWdVFuLAAAZOqy1u6Ns0mSJK9/WtWJH/z1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qmq7oO42/WjtSa7wAAwEGZ4gGknY3+Ufjj/4HPE2wiawEAwOHQPWrVD7m98OrnKs6drAUAAC+88dQ4SwLMsND9AZG1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4pO1AAAA4qvNWgAAAMzs/wH5y3s90fuVLQAAAABJRU5ErkJggg==" alt="" />
基本算法思想
把一个数拆分成单个数, 然后进行平方和, 对和进行比较, 如果满足和为1, 就是快乐数, 如果进入循环, 那么就不是快乐数.
代码注释分析
#include <stdio.h> bool isHappy(int n) {
int arr[]; //用于存储和不为1的值,仅仅是猜想有这么多个值
int i = ; //记录和的个数
int sum = ; //和值
int temp1, temp2; //temp1为值, temp2为余数 while (true){
do{
temp1 = n / ;
temp2 = n % ;
n = temp1;
sum = sum + temp2 * temp2; //和
} while (temp1 > ); //单个分解完成 if (sum != ){ //如果不为1,就把该和值赋值给arr
arr[i] = sum;
n = sum;
i++;
}
else{
return true;
}
for (int j = ; j < i; j++){ //对和值进行循环匹配,如果和arr中的值相同,就退出,因为出现了循环
if (sum == arr[j - ]){
return false;
}
}
sum = ;//第二次求和,必须先清零
}
} int main(){
int n;
scanf("%d", &n);
if (isHappy(n)){
printf("true\n");
}
else{
printf("false\n");
}
return ;
}
优化
经过资料查询, 对于快乐数, 有以下规律:
不是快乐数的数称为不快乐数(unhappy number),所有不快乐数的数位平方和计算,最後都会进入 4 → 16 → 37 → 58 → 89 → 145 → 42 → 20 → 4 的循环中。
优化代码
#include <stdio.h> bool isHappy(int n) {
int sum = ;
int temp1, temp2; while (true){
do{
temp1 = n / ;
temp2 = n % ;
n = temp1;
sum = sum + temp2 * temp2;
} while (temp1 > ); if (sum == ){
return true;
}
else{
if (sum == || sum == || sum == || sum == || sum == || sum == || sum == || sum == ){
return false;
}
}
n = sum;
sum = ;
}
} int main(){
int n;
scanf("%d", &n);
if (isHappy(n)){
printf("true\n");
}
else{
printf("false\n");
}
return ;
}
LeetCode判断结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABJYAAACsCAIAAACmW7H8AAAVmklEQVR4nO3dz4sc14EH8P2f6tSMBjEXBds4IGNW0MrBAkOQfRCLhDy24zEWG2yQDoZJjFkLedCCWaMIpNU6EA9IDEpYLJBFGGIQ2BmZxaDD3ObSl6H3UNXdr351VffUTOtJnw+BuKur3nvVVYL3nffq1b8MAQAAiMS/LLoBAAAAtCXCAQAAREOEAwAAiIYIBwAAEA0RDgAAIBoiHAAAQDREOAAAgGiIcAAAANEQ4QAAAKIhwgEAAERDhAMAAIiGCAcAABANEQ4AACAaIhwAAEA0RDgAAIBoiHAAAADREOFoYW9vb9FNAAAAhp1EuL3tO+vvnTl5YrmXJEmSJEsrL/XPXr5+/8d5e/23LyRJkry+/veDt63W39dfT5IkuXA7knLbVFrSWz5x8sx763e2D5K/9rZvvP/a0lwnVLyQR3FhAQDg+XbACDd4+Nnppcr4kCTJypvXHg7mKFSEm6/Sekunr2z9Mmfh6dUQ4QAA4JlwoAi3+83qSprVrtx58PNuFtf2nm7fv776616SJMnK6je7Mxerpz+jNMKVfrDB7s/b96+//9pSkiRJ79T6XHn6IBGuuigXFgAA5neQCLf71dkkSZLXP63KBoO/fvJKkiTJb754PGu5evozqolwmcGTmxdW5v9FRTgAAHiGHCTCNUwaLH1dt3/tfLvBDzcvnXl5KUmSZGmlf774UNdkvyd31996dbmXJElv+dW31tNJg8Wtd58ESbOiLb98d/3SmVezJ/qWVk6euXSj9BBZ4z7V57i3fePSmZMrS/VFj48b/PDnK29lu/aWXz1z6eYPjYNn0yPccDj85ea540mSHP9wM799b/vO+vl+9hRjuV3pDxwIqhg8+d/rl8/2c09Anv8i9xu3mEg5+OHP6+f72Q/TWz5RKgIAAMg5SITbufZGkiTJK7/fardcxmwR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qIPebFWEC5paSFDlCFeqvdg9Dg6cueccFJwbdcw3NN/qQrsPyXMS4eqDb1cRLrwquSu0tlXZgqnXrf1NHwwT5m/u8KY/qrwPAMCBjDpvQR+v9pGfnfFRo85oU6e0McLV9VqLk8iaxiO67s2WtxfqaB3hqof+Zu05h3sGqTN/qSrOYPzjHXK//DmJcPnrGf5iRxXhZkra7Yeew5sxdweH/yTbJkcAABYvN+/xyCNcVW9xvgjXRW+26lm4YbnUTiJci55zRcYV4Q5F8RbLp7ijiHDNY80VTU7CltQ/ANoU4eqOAADgWVDRUQwT16wTKQ8U4Wp7rbNOpOysNztThKuccDl9ImWtykbnjg7rNJGya9XPwpWf/yw/AdpZhEtLzm1uuGzFPxCU/420uenr/k4AAMCzIt9RzHVPp/VUcx3BikG0uSJcba81bEmrcYFuerNtI1zV6Fr5q2DArGLPNj3nioNzsXFUoOVMDqpmRcrCHZNeva3xvnURLszY7SPcMH9dJ/9GtyqXYS3sX3mN55lIaRYlAMCzKNfLL61oUtVTDV5/Nd5/hgjXPIZUasrOpL7GlwoUypm/N9s2wuWTWv6rneIPVftrt+g5B9djJ9+g8TdrXioAAAAQj6OYLDmNCAcAADDFlImcCyDCAQAATNX+lQSHT4QDAACIhggHAAAQDREOAAAgGiIcAABANEQ4AACAaIhwAAAA0RDhAAAAoiHCAQAAREOEAwAAiIYIBwAAEA0RDgAAIBoiHAAAQDREOAAAgGiIcAAAANEQ4QAAAKIhwgEAAERDhAMAAIiGCAcAABANEQ4AACAaIhwAAEA0RDgAAIBoiHAAAADRONIIBwAAwAEdUYQDAADgiIlwAAAA0RDhAAAAoiHCAQAAREOEAwAAiIYIBwAAEA0RDgAAIBoiHAAAQDREOAAAgGiIcAAAANEQ4QAAAKIhwgEAAERDhAMAAIiGCAcAABANEQ4AACAa/w8NmqjJT+uk4QAAAABJRU5ErkJggg==" alt="" />
Happy Number - LeetCode的更多相关文章
-
Letter Combinations of a Phone Number - LeetCode
目录 题目链接 注意点 解法 小结 题目链接 Letter Combinations of a Phone Number - LeetCode 注意点 可以不用按字典序排序 解法 解法一:输入的数字逐 ...
-
Palindrome Number - LeetCode
目录 题目链接 注意点 解法 小结 题目链接 Palindrome Number - LeetCode 注意点 负数肯定是要return false的 数字的位数要分奇数和偶数两种情况 解法 解法一: ...
-
Happy Number——LeetCode
Write an algorithm to determine if a number is "happy". A happy number is a number defined ...
-
Letter Combinations of a Phone Number leetcode java
题目: Given a digit string, return all possible letter combinations that the number could represent. A ...
-
Largest Number——LeetCode
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
-
Letter Combinations of a Phone Number——LeetCode
Given a digit string, return all possible letter combinations that the number could represent. A map ...
-
Ugly Number leetcode java
问题描述: Write a program to check whether a given number is an ugly number. Ugly numbers are positive n ...
-
Single Number leetcode java
问题描述: Given an array of integers, every element appears twice except for one. Find that single one. ...
-
Palindrome Number leetcode java
题目: Determine whether an integer is a palindrome. Do this without extra space. click to show spoiler ...
随机推荐
-
Zip文件压缩(加密||非加密||压缩指定目录||压缩目录下的单个文件||根据路径压缩||根据流压缩)
1.写入Excel,并加密压缩.不保存文件 String dcxh = String.format("%03d", keyValue); String folderFileName ...
-
IIS7 rename application or site
rename site 比较容易,在IIS里面就可以直接 rename,也可以用 cmd 的方式 1. 打开 cmd 2. cd C:\Windows\System32\inetsrv 3. appc ...
-
Burp Suite Walkthrough(英文版)
Burp Suite is one of the best tools available for web application testing. Its wide variety of featu ...
-
linuxcon-europe 2015 linux大会
http://events.linuxfoundation.org/events/archive/2015/linuxcon-europe
-
uva 10825 - Anagram and Multiplication(暴力)
题目链接:uva 10825 - Anagram and Multiplication 题目大意:给出m和n,要求找一个m位的n进制数,要求说该数乘以2~m中的随意一个数的结果是原先数各个位上数值的一 ...
-
JS中Number(),parseInt(),parseFloat()和自动类型转换
[参考来源] https://www.cnblogs.com/yi0921/p/6196841.html https://blog.csdn.net/u010200222/article/detail ...
-
Java多线程中对CountDownLatch的使用
CountDownLatch是一个非常实用的多线程控制工具类,称之为“倒计时器”,它允许一个或多个线程一直等待,直到其他线程的操作执行完后再执行.用给定的计数初始化CountDownLatch,其含义 ...
-
[USACO08DEC]Trick or Treat on the Farm 记忆化搜索
这一题非常水,因为每个点的下一个目的地是唯一的,可以考虑对每一个还为访问过的点dfs直接找出所有的环,同时更新每一个点能去的点的数量(即答案). 我们dfs时找到环上已经遍历过的一个点,用当前的dfn ...
-
iOS UI-集合视图(UICollectionView)
BowenCollectionViewCell.xib #import <UIKit/UIKit.h> @interface BowenCollectionViewCell : UICol ...
-
Chromium添加一段新字符串
参考:https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/tclib%7Csort:relevance/chr ...