'commit'
This commit is contained in:
19
TangDou/CSP-J/AcWingTraining/T6/449.cpp
Normal file
19
TangDou/CSP-J/AcWingTraining/T6/449.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <bits/stdc++.h>
|
||||
typedef long long LL;
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
LL n; // 使用long long确保处理大数值时不溢出
|
||||
cin >> n;
|
||||
|
||||
// 从2开始查找最小质因数
|
||||
for (LL i = 2; i * i <= n; ++i) {
|
||||
if (n % i == 0) {
|
||||
// 找到最小质因数i,较大的质数为n/i
|
||||
cout << n / i << endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// 理论上不会执行到这里,因为n是两个不同质数的乘积
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user