답안 #146733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146733 2019-08-25T18:25:03 Z miljenko_jabucica Prosjecni (COCI16_prosjecni) C++14
120 / 120
4 ms 760 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 3 ms 632 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