Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl '\n'
- using namespace std;
- int n;
- int diff(int x, int y) {
- int diff = x ^ y;
- int base = 1;
- for (int i = 1; i <= n; i++, base <<= 1)
- if (base == diff)
- return i;
- return 0;
- }
- void solve(){
- cin >> n;
- for (int i = 0; i < n*n; i++) {
- for (int j = 0; j < n*n; j++) {
- cout << diff(i, j) << " ";
- }
- cout << endl;
- }
- }
- void fastIO(){
- ios_base::sync_with_stdio(false); //cin.tie(0); cout.tie(0);
- }
- int main(){
- fastIO();
- int t = 1; //cin >> t;
- while(t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement