[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 ...
随机推荐
- SpringMVC探究-----从HelloWorld开始
1.SpringMVC简介 Spring MVC框架是有一个MVC框架,通过实现Model-View-Controller模式来很好地将数据.业务与展现进行分离. 它的设计是围绕Dispatch ...
- jsp无法访问
一直无法访问jsp: 由于Spring boot使用的内嵌的tomcat,而内嵌的tamcat是不支持jsp页面的,所有需要导入额外的包才能解决. <!-- 解决jsp无法访问 --> & ...
- 转:【专题三】自定义Web服务器
前言: 经过前面的专题中对网络层协议和HTTP协议的简单介绍相信大家对网络中的协议有了大致的了解的, 本专题将针对HTTP协议定义一个Web服务器,我们平常浏览网页通过在浏览器中输入一个网址就可以看到 ...
- winscp 怎么用私钥文件登录的,以.ppk结尾的密钥文件
Winscp默认用帐号密码登录,用私钥文件登录需要在高级选项里面的SSH--验证里面选择文件. Winscp使用的是putty作为SSH登录工具,而puttygen所生成的是以.ppk结尾的密钥文件. ...
- POJ 1330 Nearest Common Ancestors(LCA Tarjan算法)
题目链接:http://poj.org/problem?id=1330 题意:给定一个n个节点的有根树,以及树中的两个节点u,v,求u,v的最近公共祖先. 数据范围:n [2, 10000] 思路:从 ...
- Porsche Piwis Tester II Diagnostic Tool -Next Generation of PIWIS Tester KTS520
Porsche Piwis Tester II is the latest inspect equipment of Porsche Company. This is the latest profe ...
- Android屏幕适配全攻略(最权威的官方适配指导)
摘自:http://www.cocoachina.com/android/20151030/13971.html Android屏幕适配出现的原因 在我们学习如何进行屏幕适配之前,我们需要先了解下为什 ...
- 纯js实现移动端滑动控件,以上下滑动自取中间位置年龄为例;
<!-- 需求:上下滑动,在一个大的div块里显示5个小的值,滑动过程中自动获取中间位置的值 需要注意的是: 1 touchmove会多次被触发: 2 获取中间位置的值可以通过定位得top值来获 ...
- pic_scrapy_python
# _*_ coding:UTF-8 _*_ import requests,json,time,sys from contextlib import closing class get_photos ...
- reids非关系性数据库
1.Redis环境配置 下载安装地址: https://github.com/MicrosoftArchive/redis/releases 解压文件到指定的目录,D:\ChromeCoreDown ...