Advertisement
anhkiet2507

TongUocSo

Jul 17th, 2021
2,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(){
  4.     int N, i, X, CanX, j, k, USngtomax=5;
  5.     long long TongUS=0;
  6.     int Songto[250], Nngto=2, FirstTime=0;
  7.     Songto[0]=2; Songto[1]=3;
  8.     for(j = 5; j<=1500; j=j+2){
  9.         for(k=0;k<Nngto;k++){
  10.             if(j%Songto[k]==0){
  11.                 break;
  12.             }
  13.         }
  14.         if(k==Nngto){
  15.             Songto[Nngto]=j;
  16.             Nngto++;
  17.         }
  18.     }
  19.     scanf("%ld", &N);
  20.     for(i=1;i<=N;i++){
  21.         scanf("%d", &X);
  22.         CanX = sqrt(X);
  23.         for(j=0;Songto[j]<=CanX;j++){
  24.             while(X%Songto[j]==0){
  25.                 TongUS += Songto[j];
  26.                 X /= Songto[j];
  27.             }
  28.         }
  29.         if(X!=1){
  30.             TongUS += X;
  31.         }
  32.     }
  33.     printf("%lld", TongUS);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement