POJ1528问题解答
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include<numeric>
using namespace std;
int main()
{
vector<int> inputNums;
vector<int> results;
while (true)
{
int num;
scanf_s("%d", &num);
if (num == 0)
{
break;
}
inputNums.push_back(num);
}
for (int i = 0; i < inputNums.size(); i++)
{
int num = inputNums[i];
vector<int> divisors;
for (int j = 1; j < (num / 2 + 1); j++)
{
if (num % j == 0)
{
divisors.push_back(j);
}
}
int sum = std::accumulate(divisors.begin(), divisors.end(), 0);
int result;
if (num > sum)
{
result = 1;
}
else if (num < sum)
{
result = -1;
}
else
{
result = 0;
}
results.push_back(result);
}
printf("PERFECTION OUTPUT\n");
for (int i = 0; i < results.size(); i++)
{
int result = results[i];
if (result>0)
{
printf("%5d DEFICIENT\n",inputNums[i]);
}
else if (result == 0)
{
printf("%5d PERFECT\n", inputNums[i]);
}
else
{
printf("%5d ABUNDANT\n", inputNums[i]);
}
}
printf("END of OUTPUT\n");
return 0;
}
POJ1528问题解答的更多相关文章
- MySQL同步常见问题解答(自己的小心得)
前几天刚刚注册了博客园,我想写一些技巧性的教程,今天给大家分享一个MySQL同步常见问题解答. Q:如果主服务器正在运行并且不想停止主服务器,怎样配置一个从服务器? A:有多种方法.如果你在某时间点做 ...
- Delphi XE5 常见问题解答
Delphi XE5 常见问题解答 有关于新即时试用的问题吗?请看看 RAD Studio 即时试用常见问答. 常见问题 什么是 Delphi? Embarcadero? Delphi? XE5 是易 ...
- SSL/TLS 高强度加密: 常见问题解答
关于这个模块 mod_ssl 简史 mod_ssl会受到Wassenaar Arrangement(瓦森纳协议)的影响吗? mod_ssl 简史 mod_ssl v1 最早在1998年4月由Ralf ...
- Android Studio 中 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileDebugAidl'.的问题解答
Android Studio 中 FAILURE: Build failed with an exception. * What went wrong: Execution failed for ta ...
- Hadoop科普文——常见的45个问题解答(CSDN)
Hadoop科普文——常见的45个问题解答 1.Hadoop集群可以运行的3个模式? 单机(本地)模式 伪分布式模式 全分布式模式 2. 单机(本地)模式中的注意点? 在单机模式(standalon ...
- [!!!!!]Inno Setup教程-常见问题解答
[转]Inno Setup教程-常见问题解答 功能 * 翻译 Inno Setup 文字 * 它支持 MBCS (多字节字符集) 吗? * 将来会支持 Windows Installer 吗? ...
- PHP常用函数和常见疑难问题解答
PHP常用库函数介绍 一.PHP字符串操作常用函数 1.确定字符串长度 int strlen(string str) 2.比较两个字符串 a. strcmp函数对两个字符串进行二进制安全的比较,并区 ...
- 英特尔® 实感™ SDK 前置摄像头 (F200) 常见问题解答
原文地址 https://software.intel.com/zh-cn/articles/intel-realsense-sdk-faq-for-front-facing-camera-f200? ...
- 我个人有关 Azure 网络 SLA、带宽、延迟、性能、SLB、DNS、DMZ、VNET、IPv6 等的 Azure 常见问题解答
Igor Pagliai(微软) 2014 年 9月 28日上午 5:57 年 11 月 3 年欧洲 TechEd 大会新宣布的内容). 重要提示:这篇文章中我提供的信息具有时间敏感性,因为这些 ...
随机推荐
- mac使用指南:brew的安装
官网 http://brew.sh/ 安装并且下载brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/ ...
- Hrbustoj 2252 完全背包
一个变形的完全背包 题是第一次团队赛的热身题...看别人博客看到这道题忽然就不会了 然后想了半天还是没想出来...上oj找了提交排名..发现自己弄出来的奇怪的办法居然用时最短... 问装m最低要多少的 ...
- Yii源码阅读笔记(十)
控制器类,所有控制器的基类,用于调用模型和布局,输出到视图 namespace yii\base; use Yii; /** * Controller is the base class for cl ...
- Arrays类的十大用法
还有很多地方需要细细斟酌 0. 声明数组 String[] aArray = new String[5]; String[] bArray = {"a","b" ...
- 控制变量法-初中物理-Nobel Lecture, December 12, 1929-php执行SET GLOBAL connect_timeout=2效果
$link = mysqli_connect("localhost", "wu", "wp", "wdb"); $sql ...
- kafka监控系统
Metrics-Java版的指标度量工具之一 Metrics-Java版的指标度量工具之二 JAVA Metrics 度量工具使用介绍1 JAVA Metrics度量工具 - Metrics Core ...
- comms.nottingham.ac.uk/learningtechnology
http://comms.nottingham.ac.uk/learningtechnology/
- foreach遍历 < 创建表 >练习题
原表如下: 效果图如下: <table border="1" width="500" height="260"><tr&g ...
- Best practice: escape, or encodeURI / encodeURIComponent
escape() Don't use it, as it has been deprecated since ECMAScript v3. encodeURI() Use encodeURI when ...
- 【Android测试】【第四节】LogCat——认识和使用
◆版权声明:本文出自胖喵~的博客,转载必须注明出处. 转载请注明出处:http://www.cnblogs.com/by-dream/p/4682321.html 什么是LogCat LogCat可以 ...