为什么 while 输出能过 for 不能
查看原帖
为什么 while 输出能过 for 不能
770457
csvoner楼主2025/1/25 16:00
#include <bits/stdc++.h>
using namespace std;

void divide(long long x)
{
	for (int i = 2; i <= x / i; i ++ )
		if (x % i == 0)
		{
			int s = 0;
			while (x % i == 0)
			{
				s ++ ;
				x /= i;
			}
			while (s -- ) printf("%d ", i);
		}
	if (x > 1) cout << x << endl;
}

int main()
{
	int n;
	cin >> n;
	
	while (n -- )
	{
		long long x;
		cin >> x;
		
		divide(x);
	}
		
	return 0;
}
2025/1/25 16:00
加载中...