标签:https user cto app reg inf rev += string
如题;就是给定一个数n,要你求一个n×n的矩阵,矩阵中的元素是 0 ~ n2-1 ,使得矩阵每一行和每一列的元素异或之后的结果相等。
https://blog.csdn.net/m0_38055352/article/details/100728821
https://blog.csdn.net/mmk27_word/article/details/100075471
首先要知道:
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15 是成立的。
所以一块一块来就行了。
1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa system("cls") 4 #include <iostream>//pair 5 #include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin); 6 #include <bitset> 7 //#include <map> 8 //#include<unordered_map> 9 #include <vector> 10 #include <stack> 11 #include <set> 12 #include <string.h>//strstr substr 13 #include <string> 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9; 15 #include <cmath> 16 #include <deque> 17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less 18 #include <vector>//emplace_back 19 //#include <math.h> 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare) 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation 23 //****************** 24 int abss(int a); 25 int lowbit(int n); 26 int Del_bit_1(int n); 27 int maxx(int a,int b); 28 int minn(int a,int b); 29 double fabss(double a); 30 void swapp(int &a,int &b); 31 clock_t __STRAT,__END; 32 double __TOTALTIME; 33 void _MS(){__STRAT=clock();} 34 void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;} 35 //*********************** 36 #define rint register int 37 #define fo(a,b,c) for(rint a=b;a<=c;++a) 38 #define fr(a,b,c) for(rint a=b;a>=c;--a) 39 #define mem(a,b) memset(a,b,sizeof(a)) 40 #define pr printf 41 #define sc scanf 42 #define ls rt<<1 43 #define rs rt<<1|1 44 typedef long long ll; 45 const double E=2.718281828; 46 const double PI=acos(-1.0); 47 //const ll INF=(1LL<<60); 48 const int inf=(1<<30); 49 const double ESP=1e-9; 50 const int mod=(int)1e9+7; 51 const int N=(int)1e3+10; 52 53 int a[N][N]; 54 void make(int x,int y,int v) 55 { 56 for(int i=x;i<=x+3;++i) 57 { 58 for(int j=y;j<=y+3;++j) 59 { 60 a[i][j]=v++; 61 } 62 } 63 } 64 65 int main() 66 { 67 int n; 68 sc("%d",&n); 69 int temp=0; 70 for(int i=1;i<=n;i+=4) 71 { 72 for(int j=1;j<=n;j+=4) 73 { 74 make(i,j,temp); 75 temp+=16; 76 } 77 } 78 for(int i=1;i<=n;++i) 79 { 80 for(int j=1;j<=n;++j) 81 pr("%d ",a[i][j]); 82 pr("\n"); 83 } 84 return 0; 85 } 86 87 /**************************************************************************************/ 88 89 int maxx(int a,int b) 90 { 91 return a>b?a:b; 92 } 93 94 void swapp(int &a,int &b) 95 { 96 a^=b^=a^=b; 97 } 98 99 int lowbit(int n) 100 { 101 return n&(-n); 102 } 103 104 int Del_bit_1(int n) 105 { 106 return n&(n-1); 107 } 108 109 int abss(int a) 110 { 111 return a>0?a:-a; 112 } 113 114 double fabss(double a) 115 { 116 return a>0?a:-a; 117 } 118 119 int minn(int a,int b) 120 { 121 return a<b?a:b; 122 }
标签:https user cto app reg inf rev += string
原文地址:https://www.cnblogs.com/--HPY-7m/p/11594178.html