最小公倍數
/***************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
char x[10000000];
main()
{
int a,b,c;
int math[5200]={0};
int m=1;
math[0]=2;
for(a=3;a<50000;a=a+2)/*5W*5W已經2.5E 無須建更大*/
{
int flag=0;
for(b=0;math[b]<=sqrt(a);b++)
{
if(a%math[b]==0)
{
flag=1;
break;
}
}
if(flag==0)
{
math[m]=a;
m++;
}
}
while(gets(x)!=0)
{
a=strlen(x);
if(x[0]=='0'&&strlen(x)==1) break;
int temp1=0,max=0;
int ans[101]={0},top=0;
long long int ans2=1;
for(c=0;c<a;c++)
{
if(x[c]<=57&&x[c]>=48)
temp1=temp1*10+x[c]-48;
else
{
ans[top]=temp1;
top++;
if(temp1>=max)
max=temp1;
temp1=0;
}
}
ans[top]=temp1;
top++;
if(temp1>=max)
max=temp1;
for(a=0;a<m&&math[a]<max;a++)
{
int flag=0;
for(b=0;b<top;b++)
{
if(ans[b]%math[a]==0)
{
ans[b]/=math[a];
flag=1;
}
}
if(flag==1)
{
ans2*=math[a];
ans2%=100000000;
a--;
}
}
for(a=0;a<top;a++)
for(b=a+1;b<top;b++)
if(ans[a]==ans[b])
ans[b]=1;
for(a=0;a<top;a++)
{
ans2*=ans[a];
ans2%=100000000;
}
printf("%lld\n",ans2);
}
return 0;
}
下一篇:好累的小玫