Submission #4301333


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=505;
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);
}
bool isp[300000]={0};
vector<int> p;

int main()
{
	IOS;


	for(int i=2;i<300000;i++){
		if(!isp[i]) p.pb(i);
		for(int j=0;i*p[j]<300000;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 2151 Byte
Status
Exec Time 352 ms
Memory 5504 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
× 1
× 4
× 4
Set Name Test Cases
Sample sample_01.txt
All sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt
Case Name Status Exec Time Memory
sample_01.txt 36 ms 3328 KB
test_01.txt 352 ms 5504 KB
test_02.txt 152 ms 5376 KB
test_03.txt 31 ms 2816 KB
test_04.txt 32 ms 2816 KB
test_05.txt 32 ms 2816 KB
test_06.txt 142 ms 4096 KB
test_07.txt 131 ms 2816 KB