题解 | #完数与盈数#
完数与盈数
https://www.nowcoder.com/practice/df0d850e41894d06a165bf445ec8a8b4
#include <iostream> #include <vector> using namespace std; int main() { vector<int>wan,yin; for(int i =2;i<=60;i++){ int sum=0; for(int j=1;j<i;j++) if(i%j==0)sum+=j; if(sum == i)wan.push_back(i); if(sum >i)yin.push_back(i); } cout<<"E: "; for(int i =0;i<wan.size();i++) cout<<wan[i]<<" "; cout<<"G: 2 "; for(int i =0;i<yin.size();i++){ if(i<yin.size()-1)cout<<yin[i]<<" "; else cout<<yin[i]; } } // 64 位输出请用 printf("%lld")
E输出完不要换行