83_long_array.sy 1017 Bytes
Newer Older
龚平's avatar
init  
龚平 committed
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
const int N = 10000;

int long_array(int k) {
  int a1[N];
  int a2[N];
  int a3[N];
  int i = 0;
  while (i < N) {
    a1[i] = (i * i) % 10;
    i = i + 1;
  }
  i = 0;
  while (i < N) {
    a2[i] = (a1[i] * a1[i]) % 10;
    i = i + 1;
  }
  i = 0;
  while (i < N) {
    a3[i] = (a2[i] * a2[i]) % 100 + a1[i];
    i = i + 1;
  }
  int ans = 0;
  i = 0;
  while (i < N) {
    if (i < 10) {
      ans = (ans + a3[i]) % 1333;
      putint(ans);
    }
    else if (i < 20) {
      int j = N / 2;
      while (j < N) {
        ans = ans + a3[i] - a1[j];
        j = j + 1;
      }
      putint(ans);
    }
    else if (i < 30) {
      int j = N / 2;
      while (j < N) {
        if (j > 2233) {
          ans = ans + a2[i] - a1[j];
          j = j + 1;
        }
        else {
          ans = (ans + a1[i] + a3[j]) % 13333;
          j = j + 2;
        }
      }
      putint(ans);
    }
    else {
      ans = (ans + a3[i] * k) % 99988;
    }
    i = i + 1;
  }
  return ans;
}

int main() {
  return long_array(9);
}