Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <algorithm>
- #include <iostream>
- #include <iomanip>
- #include <cstring>
- #include <cmath>
- #include <sstream>
- #include <set>
- #include <string>
- #include <vector>
- #include <list>
- #include <map>
- using namespace std;
- int m[22][22];
- int d[20];
- int n = 20, pos;
- bool was[1000] = {};
- int main() {
- cin >> n;
- int mx = 0;
- for (int i=1; i<n; i++){
- d[i] = d[i-1] + 1;
- while (1){
- bool good = true;
- for (int j=0; j<i; j++){
- if (was[d[i] + d[j]]){
- good = false;
- break;
- }
- }
- if (good)
- break;
- d[i]++;
- }
- for (int j=0; j<i; j++){
- was[d[i] + d[j]] = true;
- }
- }
- for (int i=0; i<n; i++){
- for (int j=0; j<n; j++){
- if (i != j){
- cout << d[i] + d[j] << " ";
- } else {
- cout << "0 ";
- }
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement