fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long n,d[1000][1000],res=0,x,y;
  4. long long d1,d2;
  5. void loang(long long i,long long j)
  6. {
  7. if (i>=1 && j>=1 && i<=n && j<=n)
  8. if (i!=d1 && j!=d2)
  9. {
  10. if (d[i][j]==0)
  11. {
  12. d[i][j]=1;
  13. loang(i+2,j-1);
  14. loang(i+2,j+1);
  15. loang(i+1,j-2);
  16. loang(i+1,j+2);
  17. loang(i-2,j+1);
  18. loang(i-2,j-1);
  19. loang(i-1,j+2);
  20. loang(i-1,j-2);
  21. d[i][j]=0;
  22. }}
  23. else
  24. res+=1;
  25. }
  26. int main() {
  27. freopen("madituan.inp","r",stdin);
  28. freopen("madituan.out","w",stdout);
  29. cin>>n;
  30. cin>>x>>y;
  31. cin>>d1>>d2;
  32. loang(x,y);
  33. cout<<res;
  34. return 0;}
  35.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty