language: C# (mono-2.8)
date: 425 days 15 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
 
class SumaFacts
{
    static void Main()
    {
        long T; //casos
        long n; //numeros hallar suma factores
        int k;
 
        T = Convert.ToInt64(Console.ReadLine());
        long[] s = new long[T];
 
        for (k = 0; k < T; k++)
        {
            leeNums(out n);
            s[k] = sumafactores(n);
        }
 
        for (int c = 0; c < k; c++)
            Console.WriteLine(s[c]);
 
    }
 
    static void leeNums(out long a)
    {
        // read numbers
 
        string s;
        string[] n = new string[5000]; // separated
 
        s = Console.ReadLine();
        n = s.Split(' ');
        a = Convert.ToInt64(n[0]);
    }
 
 
    static long sumafactores(long n)
    {
        //usando el arbol de factores busca factores primos
        long c = n; //copia de n
        long[] a; // arreglo
        a = new long[10000];
 
        int l = 0; // lugares
        long s; //suma factores 
 
        s = 1;
        for (long k = 2; k <= c; k++)
            while (c % k == 0 && siprimo(k))
            {
                c /= k;
                a[l++] = k;
                s += k;
 
                for (int q = 0; q < l - 1; q++)
                    s += k * a[q];
            }
 
        return s;
 
    }
 
    static bool siprimo(long n)
    {
        // si n es primo
 
        bool s = true; // si primo (asume si)
        double r = Math.Sqrt(n); // raíz cuadrada de n
 
        for (long d = 2; s && d <= r; d++)
            if (n % d == 0) s = false;
 
        return s;
    }
}
  • upload with new input
  • result: Success     time: 3.47s    memory: 37200 kB     returned value: 0

    1
    1999999999
    2064516160