[CodeForces - 919B] Perfect Number
题目链接:http://codeforces.com/problemset/problem/919/B
AC代码:
#include<cstdio>
using namespace std;
//对全局变量或者对于一个或多个函数来说是全局的变量的时候,要注意上次用完该变量后变量的值,看其是否需要进行初始化。
int main() {
int k, index = 1, stemp, s = 19;
int arr[10005];
int sum = 0;
while (scanf("%d", &k) != EOF) {
while (index <= k) {
stemp = s;
while (stemp != 0) {
sum += stemp % 10;
stemp /= 10;
}
if (sum == 10)
arr[index++] = s;
sum = 0;
s += 9;
}
printf("%d\n", arr[k]);
index = 1; //注意
s = 19; //注意
}
return 0;
}
[CodeForces - 919B] Perfect Number的更多相关文章
- Codeforces Round #460 (Div. 2)-B. Perfect Number
B. Perfect Number time limit per test2 seconds memory limit per test256 megabytes Problem Descriptio ...
- Codeforces 919 B. Perfect Number
B. Perfect Number time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #460 (Div. 2) B Perfect Number(二分+数位dp)
题目传送门 B. Perfect Number time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces 55D Beautiful Number
Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...
- 507. Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- [LeetCode] Perfect Number 完美数字
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- [Swift]LeetCode507. 完美数 | Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- LeetCode算法题-Perfect Number(Java实现)
这是悦乐书的第249次更新,第262篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第116题(顺位题号是507).我们定义Perfect Number是一个正整数,它等于 ...
- 507. Perfect Number 因数求和
[抄题]: We define the Perfect Number is a positive integer that is equal to the sum of all its positiv ...
随机推荐
- 列表选择模式:单选、按shift、按shift或ctrl
2018-10-29 21:23:16 开始写 import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing ...
- arm cortex-m0plus源码学习(一)整体框架
Cortex-M0 分别是系统.电源管理.时钟.复位 由于.cm0p_ik_defs.v里 `define ARM_CM0PIK_IOP 0,这里的gpio是ahb接口的,画叉的部分没有例化. ah ...
- Set接口——HashSet集合
不重复,无索引,不能重复元素,没有索引: HashSet集合: 此时实现Set接口,有哈希表(HashMap的一个实例)支持,哈希表意味着查询速度很快, 是无序的,即元素的存取的顺序可能不一致: 且此 ...
- flask渲染模板时报错TypeError: 'UnboundField' object is not callable
渲染模板时,访问页面提示TypeError: 'UnboundField' object is not callable 检查代码,发现实例化表单类是,没有加括号:form = NewNoteForm ...
- 性能测试工具Locust,一个开源性能测试工具
性能测试工具Locust,一个开源性能测试工具使用Python代码来定义用户行为.用它可以模拟百万计的并发用户访问你的系统.1.它与目前主流的LoadRunner和Jmeter玩法都不一样.2.它完全 ...
- 模型(model-->orm)系统
一.ORM介绍 1)ORM概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术. 简单的说,ORM是通过 ...
- Inception 模型
https://blog.csdn.net/xxiaozr/article/details/71481356 inception v1: 去除了最后的全连接层,使用全局平均池化层来代替,因为全连接层的 ...
- 基于Theano的深度学习框架keras及配合SVM训练模型
https://blog.csdn.net/a819825294/article/details/51334397 1.介绍 Keras是基于Theano的一个深度学习框架,它的设计参考了Torch, ...
- 最新版Postman的下载及安装
1. 操作环境 Windows Windows 7旗舰版 64位 , Windows 10专业版 Postman Postman-win64-5.1.3-Setup.exe 2. Postman的资 ...
- shell脚本作为cgi程序--以web版man为例
man.cgi源码 #! /bin/sh eval `sh proccgi.sh $*` echo "Content-type: text/html" echo echo echo ...