Submission

Status:

PPPPPP----

Subtask/Task Score:

60/100

Score: 60

User: Shangbin

Problemset: โชว์ของโลมา

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-06 11:24:41

//Problem = https://grader.gchan.moe/problemset/c2_ds66_dolphin/statement
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 5;
int n, ans;

int main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    cin >> n;
    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;
}