Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Shangbin
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-06 11:29:46
//Problem = https://grader.gchan.moe/problemset/c2_ds66_dolphin/statement
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e5 + 5;
int n, ans;
signed main(){
cin.tie(nullptr)->sync_with_stdio(0);
cin >> n;
if (n == 1) return cout << 1, 0;
if (n == 2) return cout << 7, 0;
int n_even = (n % 2 == 0) ? n : n+1;
int row_left = n;
int num = (3 * n) - 2;
int start_step = 4 * (n - 3), step = 0;
for (int i = 0; i < n_even/2 - 1; i++){
row_left -= 2;
num += step;
step = start_step - (8 * i) + 2;
ans += (num % 10);
ans += ((num + 1) % 10);
//cout << num << ' ' << num + 1 << '\n';
}
if (row_left == 1){
num += 2;
ans += (num % 10);
//cout << "1 --> " << num << '\n';
}
else if (row_left == 2){
num += 6;
ans += (num % 10);
ans += ((num - 1) % 10);
//cout << "2 --> " << num << ' ' << num - 1 << '\n';
}
cout << ans;
}