Submission

Status:

P-P-P-P-P-

Subtask/Task Score:

50/100

Score: 50

User: NovemNotes

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

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-11 13:51:31

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

#define int long long

int n;
int ans=0;

int ok(int n){
    return n%10;
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    if(n<=3){
        if(n==1)cout << "1\n";
        else if(n==2)cout << "7\n";
        else cout << "24\n";
        return 0;
    }
    int st = ((2*n)+(n-2))%10;
    if(n&1){
        int idx = (n-3)/2;
        int range = 9+8*(idx-1);
        while(range){
            ans+=ok(st);st++;
            ans+=ok(st);
            st = ok(st+range);
            if(range==9)break;
            range-=8;
        }
        int last = (n*n)%10;
        ans+=last;
        last=(last-1+10)%10;
        ans+=last;
        last=(last-1+10)%10;
        ans+=last;
    }else{
        
    }
    cout << ans << "\n";
    return 0;
}