bool prime(int p) { for (int i = 2; i<= sqrt(p); i++) if (p % i== 0) return false; return true; } void Solution::solve() { cout << n << '='; if (prime(n)) cout << n << endl; else { for (int i = 2, judge = 0;;) { if (prime(i) && n % i == 0) { if (judge) cout << '*'; cout << i; n /= i; judge = 1; if (n == 1) break; } else { if (judge) cout << '*'; judge = 0; i++; } } } }
标签:int,prime,打卡,bool,5.23 From: https://www.cnblogs.com/azure011328/p/17422543.html