-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathyoung.cpp
65 lines (65 loc) · 1.3 KB
/
young.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# include <fstream>
using namespace std;
ifstream f("young.in");
ofstream g("young.out");
int i,j,n,T,p,ap[1000],ap2[1000],a[100][100],nr[1000],q,VV,NR,I,var,t;
int sol[10000];
int main ()
{
f>>n;
for (i=1; i<=n; ++i)
{
f>>nr[i];
VV+=nr[i];
for (j=1; j<=nr[i]; ++j)
a[i][j]=1;
}
for (i=1; i<=n; ++i)
{
for (j=1; j<=nr[i]; ++j)
{
NR=nr[i]-j+1;
I=i;
while (a[I+1][j])
{
++NR; ++I;
}
q=2;
while (NR>1)
{
while (NR && NR%q==0)
NR/=q, ++ap2[q];
++q;
}
}
}
//desc suma factoriala
for (i=2; i<=VV; ++i)
{
q=2; var=i;
while (var>1)
{
while (var && var%q==0)
var/=q, ++ap[q];
++q;
}
}
sol[1]=1; VV=1;
for (i=1; i<=1000; ++i)
{
for (j=1; j<=ap[i]-ap2[i]; ++j)
{
t=0;
for (q=1; q<=VV; ++q)
{
sol[q]=sol[q]*i+t;
t=sol[q]/10;
sol[q]=sol[q]%10;
}
while (t) sol[++VV]=t%10, t=t/10;
}
}
for (i=VV; i>=1; --i)
g<<sol[i];
return 0;
}