Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: colo39

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-11-18 21:05:09

#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sum = 0;int ans = 0;
    if (n % 2 != 0) {
        
        int fc = (n-3)/ 2;
        for (int i = 1;i <= n ;i++) {
            if (i == 1) {
                sum = (n-1) * 3 + 1;
                ans += to_string(sum)[to_string(sum).size()-1] - '0';
                continue;
            }

            if (i % 2 == 0) {
                sum++;
                ans += to_string(sum)[to_string(sum).size()-1] - '0';
            } else {
                sum += (fc * 8) + 1;
                ans += to_string(sum)[to_string(sum).size()-1] - '0';
                fc--;
            }
        }
    } else {
        int fc = (n-2)/ 2;
        for (int i = 1;i <= n ;i++) {
            if (i == 1) {
                sum = 3*n-2;
                ans += to_string(sum)[to_string(sum).size()-1] - '0';
                continue;
            }

            if (i % 2 == 0) {
                if (i != n) sum++;
                else sum--;
                ans += to_string(sum)[to_string(sum).size()-1] - '0';
            } else {
                sum += (fc * 8) - 3;
                ans += to_string(sum)[to_string(sum).size()-1] - '0';
                fc--;
            }
            
        }
    }

    cout << ans;

    return 0;
}