Advertisement
yicongli

HDU6440

Mar 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define gc c=getchar()
  6. #define r(x) read(x)
  7. #define ll long long
  8.  
  9. template<typename T>
  10. inline void read(T&x){
  11.     x=0;T k=1;char gc;
  12.     while(!isdigit(c)){if(c=='-')k=-1;gc;}
  13.     while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
  14. }
  15.  
  16. int main(){
  17.     int T;r(T);
  18.     while(T--){
  19.         int p;r(p);
  20.         for(int i=0;i<p;++i,puts("")){
  21.             for(int j=0;j<p;++j){
  22.                 printf("%d ",(i+j)%p);
  23.             }
  24.         }
  25.         for(int i=0;i<p;++i,puts("")){
  26.             for(int j=0;j<p;++j){
  27.                 printf("%d ",(i*j)%p);
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement