D. Number into Sequence
题面:
代码:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#define ll long long
using namespace std;
map<ll, ll> m;
ll maxx = 0;
ll maxi = 0;
void handle(ll n) {
m.clear();
maxx = 0;
ll i = 2, nn = n;
while (n > 1) {
if (i * i > n)
break;
while (n % i == 0) {
m[i]++;
n /= i;
if (m[i] > maxx) {
maxx = m[i];
maxi = i;
}
}
i++;
}
if (n > 1) {
i = n;
m[i]++;
if (m[i] > maxx) {
maxx = m[i];
maxi = i;
}
}
cout << maxx << endl;
if (maxx > 1) {
for (i = 0; i < maxx - 1; i++) {
if (i != 0)printf(" ");
cout << maxi << endl;
nn /= maxi;
}
cout << nn << endl;
} else {
cout << nn << endl;
}
}
int main() {
ll t, n;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n;
handle(n);
}
return 0;
}
就纯暴力,我都觉得没什么好说的。
这次Div3题目太水。