第二題
Never
#include<iostream> #include<vector> #include<math.h> using namespace std; int main(){ vector<long> vl, vh; // vl store factor <= sqrt(n); vh store factors > sqrt(n) long n; int sq,size; cin >> n; sq = sqrt(n); for(int i=1;i<=sq;i++){ if(n%i==0){ vl.push_back(i); if(i!=n/i) // if facotr is sqrt(n), then don't push in vh vh.push_back(n/i); } } size = vl.size(); for(int i=0;i<size;i++){ cout << vl[i] << " "; } // vh print from back for(int i=vh.size()-1;i>=0;i--){ cout << vh[i] << " "; } return 0; }
Raw Text
-
ryruyu
5 min ago
-
Breaking news - Update 1 - 11/29/2023 19:28:02
27 min ago
-
Breaking news - Update 1 - 11/29/2023 19:21:26
33 min ago
-
asdas
PHP | 46 min ago
-
sdgsdgsdg
55 min ago
-
grswgr
58 min ago
-
dfawd
59 min ago
-
Breaking news - Update 1 - 11/29/2023 18:50:22
1 hour ago
-
Untitled
1 hour ago
-
Untitled
1 hour ago