Submission
Status:
PTPTxxxxxx
Subtask/Task Score:
20/100
Score: 20
User: UNJE0o
Problemset: โชว์ของโลมา
Language: cpp
Time: 1.094 second
Submitted On: 2026-10-12 20:38:26
#include <bits/stdc++.h>
#define en '\n'
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int n,x,y;cin >> n;
unsigned long long int m = 1,mx = n*n ,arr[n][n],sum = 0;
x = 0,y = 0;
while(m != mx){
for(int j = x;j < n;j++){
arr[y][j] = m;
m+=1;
}
y+=1;
for(int j = n-1;j >= x;j--){
arr[y][j] = m;
m+=1;
}
y+=1;
for(int i = y;i < n;i++){
arr[i][x] = m;
m+=1;
}
x+=1;
for(int i = n-1;i >= y;i--){
arr[i][x] = m;
m+=1;
}
x+=1;
} arr[n-1][n-1] = m;
// for(int i = 0;i < n;i++){
// for(int j = 0;j < n;j++){
// cout << arr[i][j] << " ";
// }
// cout << en;
// }
for(int i = 0;i < n;i++){
sum += arr[n-1][i]%10;
}
cout << sum;
}