Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int a(int[] input)
  2. {
  3.     return intsqrt(intsqrt(sum_factors(input[0])))
  4.          + num_factors(input[1])*11
  5.          + intsqrt(intsqrt(sum_factors(input[2])))*2;
  6. }
  7.  
  8. int sum_factors(int n)
  9. {
  10.     int a=0,c=1;
  11.     for (n = Math.abs(n)
  12.          ;
  13.          ++c*c <= n
  14.          ;
  15.          a += n % c < 1 ? c : 0,
  16.          n /= n % c < 1 ? c-- : 1);
  17.     return a + n;
  18. }
  19.  
  20. int num_factors(int n)
  21. {
  22.     int b=1,c=1;
  23.     for (n = Math.abs(n)
  24.          ;
  25.          ++c*c <= n
  26.          ;
  27.          b += n % c < 1 ? 1 : 0,
  28.          n /= n % c < 1 ? c-- : 1);
  29.     return b;
  30. }
  31.  
  32. int intsqrt(int $)
  33. {
  34.     return (int)Math.sqrt($);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement