Pagini recente » Cod sursa (job #1451225) | Cod sursa (job #2413734) | Rating Pistol Tudor (tudor.pistol) | Cod sursa (job #1110749) | Cod sursa (job #2632727)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("sumdiv.in");
ofstream fout ("sumdiv.out");
int suma[100000];
typedef int NrMare[100000];
int main()
{
suma[0]=suma[1]=1;
int a, b;
fin>>a>>b;
//cout<<sizeof(divi)/1000000;
int d=2;
while (a>1)
{
int cnt=0, thisdiv=0;
while (a%d==0)
{
cnt++;
a/=d;
}
if (cnt>0)
{
thisdiv=cnt*b;
int prod[10000];
prod[0]=prod[1]=1;
while (thisdiv!=-1)
{
int c=0, i;
for (int i=1; i<=prod[0]; i++)
{
prod[i]=prod[i]*d+c;
c=prod[i]/10;
prod[i]%=10;
}
while (c!=0)
{
prod[0]++;
prod[prod[0]]=c%10;
c/=10;
}
thisdiv--;
}
int x=1;
while (prod[x]==0)
{
prod[x]=9;
}
prod[x]--;
int deimp=d-1;
int i, t=0;
for (i=prod[0]; i>0; i--, t%=deimp)
prod[i]=(t=t*10+prod[i])/deimp;
while(prod[0]>1&&!prod[prod[0]])
prod[0]--;
//for (int i=1; i<=prod[0]; i++)
// cout<<prod[i];
int j;
NrMare z;
z[0]=suma[0]+prod[0]-1;
for (i=1; i<=suma[0]+prod[0]; i++) z[i]=0;
for (i=1; i<=suma[0]; i++)
{
for (j=1; j<=prod[0]; j++)
{
z[i+j-1]+=suma[i]*prod[j];
}
}
for (i=1; i<=z[0]; i++)
{
t+=z[i];
z[i]=t%10;
t/=10;
}
if (t) z[++z[0]]=t;
for (i=0; i<=z[0]; i++) suma[i]=z[i];
}
d++;
}
for (int i=suma[0]; i>=1; i--) fout<<suma[i];
return 0;
}