Cod sursa(job #3315540)

Utilizator sevescu_andreisevescu andrei sevescu_andrei Data 14 octombrie 2025 18:06:46
Problema GFact Scor 50
Compilator c-64 Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <stdio.h>
#include <stdlib.h>

char ciur[33001];
int p[3700],ea[3700],eb[3700];

void desc(int e[],int n){
    int i;
    i=0;
    while(p[i]*p[i]<=n){
        while(n%p[i]==0){
            n/=p[i];
            e[i]++;
        }
        i++;
    }
    if(n>0){
        i=0;
        while(p[i]<n)
            i++;
        e[i]++;
    }
}

int main()
{
    FILE *fin ,*fout;
    int i,j,k=0,a,q,b,f;
    for(i=2;i<=33000;i++){
        if(ciur[i]==0){
            p[k++]=i;
            for(j=i+i;j<=33000;j+=i){
                ciur[j]=1;
            }

        }
    }
    printf("%d" ,p[3]);
    fin=fopen("gfact.in", "r");
    fout=fopen("gfact.out", "w");
    fscanf(fin, "%d%d" ,&a,&q);
    desc(ea ,a);
    for(i=0;i<3700;i++)
        ea[i]*=q;
    b=1;
    f=0;
    while(f==0){
        b++;
        desc(eb,b);
        f=1;
        for(i=0;i<3700;i++){
            if(eb[i]<ea[i])
                f=0;
        }
    }
    fprintf(fout, "%d" ,b);
    return 0;
}