题目链接: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的更多相关文章

  1. Codeforces Round #460 (Div. 2)-B. Perfect Number

    B. Perfect Number time limit per test2 seconds memory limit per test256 megabytes Problem Descriptio ...

  2. Codeforces 919 B. Perfect Number

      B. Perfect Number   time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. 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 ...

  4. Codeforces 55D Beautiful Number

    Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...

  5. 507. Perfect Number

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  6. [LeetCode] Perfect Number 完美数字

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  7. [Swift]LeetCode507. 完美数 | Perfect Number

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  8. LeetCode算法题-Perfect Number(Java实现)

    这是悦乐书的第249次更新,第262篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第116题(顺位题号是507).我们定义Perfect Number是一个正整数,它等于 ...

  9. 507. Perfect Number 因数求和

    [抄题]: We define the Perfect Number is a positive integer that is equal to the sum of all its positiv ...

随机推荐

  1. Sitecore CMS中配置模板部分

    如何在Sitecore CMS中配置模板部分. 注意: 本教程将扩展于“Sitecore CMS中创建模板”的章节. 配置折叠状态 配置模板部分的折叠状态允许用户选择默认折叠或展开哪些模板部分.此设置 ...

  2. 【转】查看sqlserver被锁的表以及如何解锁

    查看被锁表: select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName from sys. ...

  3. IOS 开发体验测试问题

    1.键盘收起体验 a. 文本键盘会收起,但是表情包.添加视频的键盘不会收起: b. 在会话场景中,同时进行一个点击输入框,一个向下滑,输入框中的聚焦的竖直细线不会消失:

  4. Java并发编程:volatile关键字解析-转

    Java并发编程:volatile关键字解析 转自海子:https://www.cnblogs.com/dayanjing/p/9954562.html volatile这个关键字可能很多朋友都听说过 ...

  5. 【转】Kylin系列-使用Saiku+Kylin构建多维分析OLAP平台

    关于Kylin的介绍和使用请参考之前的文章 <分布式大数据多维分析(OLAP)引擎Apache Kylin安装配置及使用示例> Kylin对外提供的是SQL查询接口,基于Kylin构建OL ...

  6. MongoDB-Java的两个基本操作Upsert和insertMany

    此文只是为了记录几个基本操作,首先Upsert,有多种方法可以进行,但是都需要指定UpdateOptions.upsert(true),其中最简单的办法如下(eqq是一个用来filter的BSON,具 ...

  7. android使用inject需要注意的地方

    android使用inject需要注意的地方1.viewmodel里面添加注解@Inject FavoritesDBManager mFavoritesDBManager; 2.Component里面 ...

  8. js数组内数字按大小排序实现函数

    正常冒泡排序: function evlabc(a) { //排序大小 var i = j = t = 0; for (i = 0; i < a.length; i++) { for (j = ...

  9. JustOj 1927: 回文串

    题目描述 回文串是从左到右或者从右到左读起来都一样的字符串,试编程判别一个字符串是否为回文串. 输入 输入一个字符串.串长度<255. 输出 判别输入的字符串是否为回文串,是输出"Y& ...

  10. 从percona server 5.7换到mariadb 10.2

    过去两年半一直推荐使用percona server,今天开始,因为一些mysql迟迟不不愿意支持的特性,打算换回mariadb 10.2了,具体哪些不说了,总之非常关键,mariadb都支持一两年了, ...