Submission #51637

# Submission time Handle Problem Language Result Execution time Memory
51637 2018-06-19T13:10:32 Z Adhyyan1252 Prosjecni (COCI16_prosjecni) C++11
120 / 120
4 ms 760 KB
#include<bits/stdc++.h>

using namespace std;
int a[101][101];
int main(){
	int n; cin>>n;
	if(n == 2){
		cout<<-1<<endl; return 0;
	}
	int count = 1;
	if(n%2 == 0){
		for(int i = 0; i < n; i++){
			if( i == n-1){
				long long csum = 0;
				for(int j = 0; j < n-1; j++){
					csum += a[j][0];
				}
				count = a[n/2][0]*n - csum;
			}
			long long sum = 0;
			for(int j = 0; j < n; j++){
				if(j == n-1) count += n/2 ;
				a[i][j] = count++;
				sum += a[i][j];
				cout<<a[i][j]<<" \t";
			}
			cout<<endl;
			//cout<<": "<<(sum*1.000)/n<<endl;
		}
	}else{
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cout<<count++<<"\t";
			}
			cout<<endl;
		}
	}
	
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 3 ms 760 KB Output is correct
10 Correct 4 ms 760 KB Output is correct