# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146733 | miljenko_jabucica | Prosjecni (COCI16_prosjecni) | C++14 | 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 n;
int mat[1000][1000];
vector<int> zbrojevi;
int main()
{
cin >>n;
for (int i = 0; i < n-1; ++i)mat[0][i] = i+1;
int add = n*(n-1)/2;
mat[0][n-1] = n*(n-1)/2;
for (int i = 1; i < n-1; ++i){
for (int j = 0; j < n; ++j){
mat[i][j] = mat[i-1][j]+add;
}
}
for (int i = 0; i < n; ++i){
int zbr = 0;
for (int j = 0; j < n-1; ++j){
zbr += mat[j][i];
}
zbrojevi.push_back(zbr);
///cout <<zbr <<" ";
}
for (int i = 0; i < n; ++i){
int x = n*mat[n-2][i]-zbrojevi[i];
mat[n-1][i] = x;
}
for (int i = 0; i < n; ++i){
for (int j = 0; j < n; ++j){
cout <<mat[i][j] <<" ";
}
cout <<"\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |