problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing725类 参考

AcWing 725. 完全数 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 725. 完全数

在文件 acwing.h818 行定义.

成员函数说明

◆ main()

int acwing::acwing725::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp2420 行定义.

2420 {
2421 unsigned short n;
2422 cin >> n;
2423 unsigned int x;
2424 for(unsigned short i = 0; i < n; i++) {
2425 cin >> x;
2426 unsigned int count = 1;
2427 const auto max = static_cast<unsigned int>(sqrt(static_cast<double>(x)));
2428 for(unsigned int j = 2; j <= max; j++) {
2429 if(x % j == 0) {
2430 count += j;
2431 count += x / j;
2432 if(j == x / j) {
2433 count -= j;
2434 }
2435 }
2436 }
2437 cout << x;
2438 if(x == 1 || count != x) {
2439 cout << " is not perfect";
2440 } else {
2441 cout << " is perfect";
2442 }
2443 cout << endl;
2444 }
2445 return 0;
2446 }

被这些函数引用 acwing::TEST().


该类的文档由以下文件生成: