145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
题目大意:
145 是一个奇怪的数字, 因为 1! + 4! + 5! = 1 + 24 + 120 = 145.
找出所有等于各位数字阶乘之和的数字之和。
注意: 因为 1! = 1 和 2! = 2 不是和的形式,所以它们不算在内。
#include<stdio.h> #include<string.h> #include<math.h> #include<ctype.h> #include<stdlib.h> #include<stdbool.h> int factorial(int n) //阶乘函数 { if(n==1 || n==0) return 1; else return n*factorial(n-1); } bool judge(int n) //判断一个整数是否符合题意的函数 { char s[10]; sprintf(s,"%d",n); int len=strlen(s); int sum=0; for(int i=0; i<len; i++) { sum+=factorial(s[i]-'0'); } if(n==sum) return true; else return false; } int main() { int sum=0; for(int i=3; i<1000000; i++) { if(judge(i)) sum+=i; } printf("%d\n",sum); return 0; }
Answer:
|
40730 |
相关推荐
今天写的Digit Recognizer属于练习项目,最后的结果只按照测试集的正确率计算排名,没有奖励。解决方案的python代码在Github开源平台上。 Digit Recognizer任务 此任务是在MNIST(一个带Label的数字像素集合)上训练...
is a hard problem. In this paper, we address an equally hard sub-problem in this domain viz. recognizing arbitrary multi-digit numbers from Street View imagery. Traditional approaches to solve this ...
1164:digit函数 时间限制: 1000 ms 内存限制: 65536 KB 提交数: 32194 通过数: 20739 【题目描述】 在程序中定义一函数digit(n,k) ,它能分离出整数n 从右边数第k 个数字。 【输入】 正整数n 和k 。 【输出】 一...
基于python实现的利用kNN实现Digit Recognition,分别从1. 准备数据,对数据进行预处理 2. 选用合适的数据结构存储训练数据和测试元组 3. 设定参数,如k 4.维护一个大小为k的的按距离由大到小的优先级队列,用于存储...
Parallels Desktop 17.1.1 for M1 M1pro (解压码digit77.com).dmg mac电脑M1系列芯片电脑
电子时钟字体文件electronicFont DS-DIGIT.TTF
Digit Recognizer手写数字识别的MINST数据集:包含三个数据文件 sample_submission.csv,test.csv,train.csv
kaggle 竞赛中的手写体数字识别数据集,Digit Recognizes数据集,分为test.csv和train.csv
matlab code for digit recognition
kaggle digit-recoginzer 数字识别数据,用于入门的手写数字识别,常用的deep learning,神经网络,机器学习数据集
matlab开发-NACA4digit。NACA 4位翼型绘图仪。
一款数码字体,类似于电子手表的字体样式,带HTML使用示例。使用时首先要引入DS-DIGIT.TTF字体文件,在HTMLcss样式添加 font-family:electronicFont;便可生效。 好像不兼容IE浏览器,谷歌使用正常
本指标实现了一个突破系统,它使用了基于 JSatl_Digit 算法处理的最高价和最低价的序列形成的通道。
HTM 算法,On the Optimum Architecture of the Biologically Inspired Hierarchical Temporal Memory Model Applied to the Hand-Written Digit Recognition
指标 ColorJFatl_Digit 在输入参数中有时间帧选项。
基于 JSatl_Digit_System 指标信号的交易系统。
Tensorflow入门,手写数字图片识别数据集,从https://www.kaggle.com/c/digit-recognizer下载的 包含train.csv,test.csv,sample_submission.csv 从官网下载要注册而且慢=。=