Cod sursa(job #3360942)

Utilizator RegeleOu3433Calin V. Dragos Andrei RegeleOu3433 Data 17 iulie 2026 16:41:10
Problema Sum Scor 50
Compilator c-64 Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <stdio.h>
#define MAXX 200000

int cmmdc ( int a , int b ) {
    int auxr;

    while ( b > 0 ) {
        auxr = a % b;
        a = b;
        b = auxr;
    }

    return a;
}
int main () {
    FILE *fin , *fout;
    int n , i , j , x;
    long long px;

    fin = fopen ( "sum.in" , "r" );
    fscanf ( fin , "%d" , &n );
    fout = fopen ( "sum.out" , "w" );

    for ( i = 0 ; i < n ; i++ ) {
        fscanf ( fin , "%d" , &x );
        px = 0;
        for ( j = 1 ; j <= 2 * x ; j++ )
            if ( cmmdc ( x , j ) == 1 )
                px = px + x;
        fprintf ( fout , "%lld\n" , px );
    }
    fclose ( fin );
    fclose ( fout );
    return 0;
}