1.3.4Combination Lock

  
    
  1. /*
  2. ID: awsd1231
  3. PROG: combo
  4. LANG: C++
  5. */
  6. #include<iostream>
  7. #include<cstdio>
  8. #include<cmath>
  9. using namespace std;
  10. int n, num[2][3];
  11. int one() {
  12. int a[3] = {0};
  13. for(int i = 0; i != 3; ++i) {
  14. if(abs(num[0][i] - num[1][i]) < 5)
  15. a[i] = 5 - abs(num[0][i] - num[1][i]);
  16. else if(n-abs(num[0][i] - num[1][i]) < 5)
  17. a[i] = 5 - n + abs(num[0][i] - num[1][i]);
  18. }
  19. return a[0] * a[1] * a[2];
  20. }
  21. int main() {
  22. freopen("combo.in", "r", stdin);
  23. freopen("combo.out", "w", stdout);
  24. cin >> n;
  25. for(int i = 0; i != 3; ++i) //农夫
  26. cin >> num[0][i];
  27. for(int i = 0; i != 3; ++i) //预设
  28. cin >> num[1][i];
  29. if(n < 6)
  30. cout << n*n*n << endl;
  31. else
  32. cout << 250 - one() << endl;
  33. return 0;
  34. }





你可能感兴趣的:(Lock)