题解 | #Problem A#
Problem A
https://www.nowcoder.com/practice/ee083fda4b39446d9aa543b1039475b8
#include <iostream> #include <vector> using namespace std; //6 1 2 3 6 bool check(int x){ int res = 0; if(x == 1) return false; for(int i = 2; i <= x / i; i ++){ if(x % i == 0){ res += i; if(x / i != i) res += x / i; } } if(res + 1 == x) return true; return false; } int main(){ vector<int> v; for(int i = 5; i < 1e5; i ++){ if(check(i)) v.push_back(i); //v.insert(v.end(), i); } int l, r; while(cin>>l>>r){ for(auto t: v){ if(t >= l && t <= r) cout<<t<<endl; } } return 0; }