创造题意,最为致命
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <map>
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
using namespace std;
int t, n,color,en,res[1111];
int main() {
cin >> t;
while (t--) {
map <int, int> mm;
color = 1;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> en;
for (int j = 2; j <= 31; j++)
if (en%j == 0) {
if (mm.count(j) <= 0)
mm[j] = color++;
res[i] = mm[j];
break;
}
}
cout << (color - 1) << endl;
for (int i = 0; i < n; i++)
cout << res[i] << ' ';
cout << endl;
}
return 0;
}
1665

被折叠的 条评论
为什么被折叠?



