洛谷 P1075质因数分解题解--zhengjun

题面传送门

思路

不就一道模拟吗,于是我就从\(n\)开始找,结果\(T\)了,然后,就想到了从小到大找,找到了就输出\(n\div i\),结果就\(A\)

代码

#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin>>n;
	for(int i=2;i*i<=n;i++)
		if(n%i==0){
			cout<<n/i;
			break;
		}
	return 0;
}

谢谢--zhengjun

posted @ 2022-06-10 19:52  A_zjzj  阅读(20)  评论(0编辑  收藏  举报