# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51637 | Adhyyan1252 | Prosjecni (COCI16_prosjecni) | C++11 | 4 ms | 760 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |