Submission
Status:
PPPPPP----
Score: 60
User: Punnawith
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.002 second
Submitted On: 2025-03-23 14:54:09
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
if(n == 1) {
cout << 1;
return 0;
}
if(n == 2) {
cout << 2;
return 0;
}
ll num = 0;
ll nextN = n;
ll sum = 0;
while(nextN >= 2) {
num = num + (nextN * 2) - 2 + nextN;
if(num == n * n) {
sum += ((num % 10) + ((num - 1) % 10));
} else {
sum += ((num % 10) + ((num + 1) % 10));
}
num += nextN - 2;
nextN -= 2;
}
if(n % 2 == 1) {
sum += (n * n) % 10;
}
cout << sum;
}