fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <array>
  6.  
  7. using namespace std;
  8.  
  9. array<array<int,10>,10> Cardano(unsigned long long n)
  10. {
  11. array<array<int,10>,10> m;
  12.  
  13. for(int i = 0; i < 10; ++i)
  14. for(int j = 0; j < 10; ++j)
  15. m[i][j] = 0;
  16.  
  17.  
  18. for(int i = 0; i < 25; ++i)
  19. {
  20. int q = n&0x3;
  21. n >>= 2;
  22. int rr = i/5, cc = i%5, r, c;
  23. switch(q)
  24. {
  25. case 0: r = rr; c = cc; break;
  26. case 1: r = cc; c = 9 - rr; break;
  27. case 2: r = 9 - rr; c = 9 - cc; break;
  28. case 3: r = 9 - cc; c = rr; break;
  29. }
  30. m[r][c] = 1;
  31. }
  32. return m;
  33. }
  34.  
  35.  
  36.  
  37. int main()
  38. {
  39. unsigned long long No = 1037896401234567ull;
  40. auto L = Cardano(No);
  41. for(auto r: L)
  42. {
  43. for(auto c: r) cout << c;
  44. cout << endl;
  45. }
  46. }
  47.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
0010000000
0010000101
1000001000
1000000100
0000000100
0101101100
0101000010
0000000100
0000100011
1000111000