标签:flag ios -- pre 因式分解 ret namespace als nbsp
1 #include <iostream> 2 using namespace std; 3 bool flagM, flagN; 4 void dfs(int m, int n, int factor){ 5 if (m == 1 && n == 1){//两个都被完全因式分解 6 flagM = flagN = true; 7 //printf("return;\n"); 8 return; 9 } 10 if (n == 1)//小数被分解完,大数还未被分解完 11 flagN = true; 12 while (factor>1){ 13 14 if (m%factor == 0) { 15 //printf("m:%d,factor:%d\n", m, factor); 16 dfs(m / factor, n, factor - 1); 17 } 18 19 if (n%factor == 0) { 20 //printf("n:%dfactor:%d\n",n,factor); 21 dfs(m, n / factor, factor - 1); 22 } 23 factor--; 24 } 25 } 26 int main(){ 27 int m, n; 28 while (cin>>m>>n){ 29 if (m<n){ 30 int t = m; 31 m = n; 32 n = t; 33 } 34 flagM = flagN = false; 35 dfs(m, n, 100); 36 if (!flagM && flagN) 37 cout << n << endl; 38 else 39 cout << m << endl; 40 } 41 return 0; 42 }
标签:flag ios -- pre 因式分解 ret namespace als nbsp
原文地址:https://www.cnblogs.com/miyamochio/p/9675866.html