QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#601626 | #9309. Graph | SATSKY | WA | 7ms | 3568kb | C++20 | 2.0kb | 2024-09-30 09:15:41 | 2024-09-30 09:15:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
#define int long long
struct node {
int fa, sz;
long long g;
} f[N];
int find(int x) {
return f[x].fa == x ? x : f[x].fa = find(f[x].fa);
}
void uni(int x, int y) {
int fx = find(x), fy = find(y);
if (fx == fy)return;
f[fy].fa = fx;
f[fx].sz += f[fy].sz;
}
long long pruf(vector<int> vec) {
vec.push_back(1);
if (vec.size() <= 1)return 1;
int ans = 1, sum = 0;
for (auto x: vec) {
ans = ans * x;
sum += x;
}
for (int i = 1; i <= vec.size() - 2; i++)ans = ans * sum;
return ans;
}
long long solve(int x) {
for (int i = 1; i <= x; i++) {
f[i].fa = i;
f[i].sz = 1;
f[i].g = 1;
}
vector<int> vec;
long long mul = 1;
for (int i = x; i >= 1; i--) {
for (int j = i + i; j <= x; j += i) {
if (f[j].fa == j) {
vec.push_back(f[j].sz);
mul *= f[j].g;
uni(i, j);
}
}
f[i].g = mul * pruf(vec);
vec.clear();
}
return f[1].g;
}
signed main() {
int pre=0,precnt=2;
for (int i = 2; i <=30; i++) {
int ans=solve(i);
int cnt=0;
while(ans%i==0){
ans/=i;
cnt++;
if(cnt==precnt){
if(ans%i==0 && ans/i==pre){
ans/=i;
cnt++;
}
break;
}
}
pre=ans;
precnt=cnt;
cout<<i<<" "<<cnt<<" "<<ans<<"\n";
for(int j=2;1ll*j*j<=ans;j++){
while(ans%j==0){
cout<<j<<'*';
ans/=j;
}
}
cout<<ans<<'\n';
}
return 0;
}
/*
1
1
3
8
50
144
1372
6144
39366
108000
1581228
7962624
142576512
413048832
2624400000
28991029248
667355507712
2938656153600
77230518249600
393216000000000
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 3568kb
input:
4
output:
2 0 1 1 3 1 1 1 4 1 2 2 5 2 2 2 6 2 4 2*2*1 7 3 4 2*2*1 8 3 12 2*2*3 9 3 54 2*3*3*3*1 10 3 108 2*2*3*3*3*1 11 4 108 2*2*3*3*3*1 12 4 384 2*2*2*2*2*2*2*3 13 5 384 2*2*2*2*2*2*2*3 14 5 768 2*2*2*2*2*2*2*2*3 15 5 3456 2*2*2*2*2*2*2*3*3*3*1 16 5 27648 2*2*2*2*2*2*2*2*2*2*3*3*3*1 17 6 27648 2*2*2*2*2*2*2...
result:
wrong answer expected '8', found '2'