Submission

Status:

-PPP-P-PPP

Subtask/Task Score:

70/100

Score: 70

User: kimza

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

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-05 09:29:23

#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    long long n;
    cin >> n;
    long long x = (n+2-1)/2;
    long long a = 3,b = 2; //an-b
    long long bdif = 10;
    long long sum = 0;
    if(n==1){
        cout << "1";
    }
    else if(n==2){
        cout << "7";
    }
    else{
        for(int i=0;i<x-1;i++){
            sum += (((a*n)-b)%10)+((((a*n)-b)+1)%10);
            //cout << (a*n)-b  << " " << (a*n)-b + 1 << " ";
            a+=4;
            b+=bdif;
            bdif+=8;
        }
        //cout << sum << " ";
        //cout << (((a*n)-b));
        if(n%2==0) sum += (((a*n)-b)%10)+((((a*n)-b)-1)%10);
        else sum += (((a*n)-b)%10)+((((a*n)-b)+1)%10);
        cout << sum;
    }
    
    return 0;
}