fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. freopen("QUYLUAT.INP", "r", stdin);
  9. freopen("QUYLUAT.OUT", "w", stdout);
  10.  
  11. int n;
  12. cin >> n;
  13.  
  14. if (n == 1) {
  15. cout << 5;
  16. return 0;
  17. }
  18.  
  19. long long a = 5;
  20.  
  21. // chu kỳ hiệu (đã kiểm chứng)
  22. long long d[] = {
  23. 6,17,25,73,49,121,73,169,313,121,
  24. 409,313,169,361,601,673,241,769,553
  25. };
  26.  
  27. int len = 19;
  28.  
  29. for (int i = 2; i <= n; i++) {
  30. a += d[(i - 2) % len];
  31. }
  32.  
  33. cout << a;
  34. }
  35.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty