#include<cstdio>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
long long visit[10000][10000]={{0}},ans[10000][10000]={{0}};
main()
{
long long i,n1,j;
for(i=2;i<10000;i++)
{
n1=i;
for(j=2;n1!=1;j++)
{
while(n1%j==0)
{
n1/=j;
visit[i][j]++;
}
}
for(j=2;j<=i;j++)
{
ans[i][j]=ans[i-1][j]+visit[i][j];
}
}
long long ts,cs=1;
cin>>ts;
while(ts--)
{
long long n,m,ans1=10000000000;
cin>>n>>m;
for(i=2;i<=n&&ans1;i++)
{
if(visit[n][i])
{
ans1=min( ans1,(ans[m][i]/visit[n][i]));
}
}
if(ans1==0)
{
printf( "Case %lld:\nImpossible to divide\n", cs++ );
}
else
printf( "Case %lld:\n%lld\n", cs++, ans1 );
}
}
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
long long visit[10000][10000]={{0}},ans[10000][10000]={{0}};
main()
{
long long i,n1,j;
for(i=2;i<10000;i++)
{
n1=i;
for(j=2;n1!=1;j++)
{
while(n1%j==0)
{
n1/=j;
visit[i][j]++;
}
}
for(j=2;j<=i;j++)
{
ans[i][j]=ans[i-1][j]+visit[i][j];
}
}
long long ts,cs=1;
cin>>ts;
while(ts--)
{
long long n,m,ans1=10000000000;
cin>>n>>m;
for(i=2;i<=n&&ans1;i++)
{
if(visit[n][i])
{
ans1=min( ans1,(ans[m][i]/visit[n][i]));
}
}
if(ans1==0)
{
printf( "Case %lld:\nImpossible to divide\n", cs++ );
}
else
printf( "Case %lld:\n%lld\n", cs++, ans1 );
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন