HDU 1323 Perfection (水题)
来源:互联网 发布:淘宝宝贝评价没有了 编辑:程序博客网 时间:2024/05/01 08:22
题目大意:输入一系列数,以0结尾。最多100个 且每个数最大不超过60000. 然后求出每个数的所有真因子(即不包括本身的因子)之和。
由于 , 数据比较小, 可以直接暴力来解,另外注意输出格式即可。
代码
#include <iostream>#include <iomanip>using namespace std;const int maxn = 110;int main(){ int a[maxn] , b[maxn] , n = 0; while(cin >> a[n] && a[n]) n++; for(int i = 0; i < n; i++) { int tmp = 0; for(int j = a[i] / 2; j >= 1; j--) if(a[i] % j == 0) tmp += j; b[i] = tmp; } cout << "PERFECTION OUTPUT" << endl; for(int i = 0; i < n; i++) { cout << setw(5) << a[i] << " "; if(b[i] == a[i]) cout << "PERFECT" << endl; else if(b[i] > a[i]) cout << "ABUNDANT" << endl; else cout << "DEFICIENT" << endl; } cout << "END OF OUTPUT" << endl; return 0;}
0 0
- HDU 1323 Perfection (水题)
- POJ 1528 && HDU 1323 Perfection(水~)
- HDU 1323 Perfection(公因子)
- HDU 1323 Perfection
- hdu 1323 Perfection
- hdu 1323 Perfection
- HDU 1323 Perfection
- hdu 1326(Perfection)(水题)
- HDU 1323 Perfection
- 杭电 HDU ACM 1323 Perfection
- HDOJ 1323 Perfection(简单题)
- hdoj.1323 Perfection 20140819
- hdoj 1323 Perfection
- Perfection
- hdu 1528 Perfection(数论·因子和·C++·java)
- 杭电 OJ 1323 Perfection
- poj 1528 Perfection(素数分解)
- nyist 月老的烦恼(一)||zoj 1284 Perfection
- ZBar扫码
- CADisplayLink
- C++——运算符重载(四)
- PMI-ACP敏捷认证:敏捷开发的6个实战经验
- Spring+MyBatis多数据源配置实现
- HDU 1323 Perfection (水题)
- 2015-0909-osg学习历程8
- mysql远程连接 Host * is not allowed to connect to this MySQL server问题解决方法
- iOS,关于真机tableViewCell上面button响应事件,不同版本崩溃问题解决
- Thrift学习笔记
- Linux初学者的简易脚本----自动配IP
- .net后台输出js关闭当前浏览器窗口
- linux多线程学习
- iOS GCD同步队列和同步任务 堵塞和死锁