Submission #4301320


Source Code Expand

Copy
/*input
3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=30005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll g[maxn][maxn];

vector<int> a,b;

ll lcm(ll a,ll b){
	if(a==0||b==0) return a+b;
	return a*b/__gcd(a,b);
}

int main()
{
	IOS;

	bool isp[maxn]={0};
	vector<int> p;

	for(int i=2;i<maxn;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<maxn;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
	REP(i,500) a.pb(p[i]);
	REP(i,500) b.pb(p[i+500]);

	REP(i,500) REP(j,500) if((i+j)%2==0){
		g[i][j]=1;
		g[i][j]*=a[(i+j)/2];
		g[i][j]*=b[(i-j+499)/2];
	}

	REP(i,500) REP(j,500) if((i+j)%2){
		g[i][j]=0;

		if(i+1<500) g[i][j]=lcm(g[i][j],g[i+1][j]);
		if(j+1<500) g[i][j]=lcm(g[i][j],g[i][j+1]);
		if(i) g[i][j]=lcm(g[i][j],g[i-1][j]);
		if(j) g[i][j]=lcm(g[i][j],g[i][j-1]);
		g[i][j]++;
		assert(g[i][j]<1e15);
	}
	int n;
	cin>>n;
	REP(i,n) REP(j,n) cout<<g[i][j]<<" \n"[j==n-1];

	REP(i,n) REP(j,n-1) assert(max(g[i][j],g[i][j+1])%min(g[i][j],g[i][j+1])==1);

	return 0;
}

Submission Info

Submission Time
Task D - Modulo Matrix
User iloveUtaha
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2149 Byte
Status

Compile Error

/tmp/cc1tqF0C.o: In function `_GLOBAL__sub_I__Z5mypowxx':
Main.cpp:(.text.startup+0xba5): relocation truncated to fit: R_X86_64_32 against `.bss'
Main.cpp:(.text.startup+0xbb4): relocation truncated to fit: R_X86_64_32 against `.bss'
collect2: error: ld returned 1 exit status