Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1014    Accepted Submission(s): 200
Special Judge


Problem Description
Freshmen frequently make an error in computing the power of a sum of real numbers, which usually origins from an incorrect equation p is a prime, the identity
p

holds true for every pair of non-negative integers p. Power is defined as
0


Obviously there exists an extremely simple solution that makes all operation just produce zero. So an extra constraint should be satisfied that there exists an integer p ought to be closed under the operation of your definitions.

Hint

Hint for sample input and output:
From the table we get 1.
They are the same.
 

 

Input
The first line of the input contains an positive integer p is guranteed to be a prime.
 

 

Output
For each test case, you should print ).
 

 

Sample Input
1 2
 

 

Sample Output
0 1 1 0 0 0 0 1

 

分析:比赛的时候做出来的队友说的是数论结论题,比赛后我是按照题目意思直接模拟A掉的。。
  根据题目给出的数字p按照题目的意思我们可以得到一个2*p行,p列的矩阵
  其中1<=i<=p,1<=j<=p时:mapn[i][j] = ((i-1)+(j-1))%p
    p+1<=i<=2*p,1<=j<=p时:mapn[i][j] = ((i-1)*(j-1))%p
AC代码:
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = pow(2,10)+10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
const double pi = acos(-1.0);
ll mapn[2*maxn][maxn];
int main() {
    ll T, p;
    scanf("%lld",&T);
    while(T--) {
        memset(mapn,0,sizeof(mapn));
        scanf("%lld",&p);
        for( ll i = 1; i <= 2*p; i ++ ) {
            for( ll j = 1; j <= p; j ++ ) {
                if( i <= p ) {
                    mapn[i][j] = ((i-1)+(j-1))%p;
                } else {
                    mapn[i][j] = (i-1)*(j-1)%p;
                }
                if( j != p ) {
                    printf("%lld ",mapn[i][j]);
                } else {
                    printf("%lld\n",mapn[i][j]);
                }
            }
        }
    }
    return 0;
}

  

相关文章:

  • 2021-12-21
  • 2021-12-21
  • 2021-12-06
  • 2021-10-19
  • 2021-12-21
  • 2021-11-20
  • 2021-12-31
猜你喜欢
  • 2021-11-03
  • 2021-11-03
  • 2021-05-19
  • 2021-11-13
  • 2021-12-31
  • 2021-12-21
  • 2021-12-31
  • 2021-12-22
相关资源
相似解决方案