Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Seng

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

Language: cpp

Time: 0.003 second

Submitted On: 2026-05-31 20:59:15

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

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	ll n = 8;cin >> n;
	ll x = 2;
	ll ans = 0;
	ll add = 0;
	add = 2*n;
	if(n == 1) cout << 1;
	else if(n == 2) cout << 7;
	else if(n == 3) cout << 24;
	else{
		while(n-x >= 0){
		add += n-x;
		if(add >= n*n) add = n*n-1;
		ans += (add)%10 + (add+1)%10;
		//cout << add << " " << add+1 << '\n';
		add += 3*(n-x);
		x+=2;
		}
		//cout << '\n';
		if(n%2 != 0) ans += (n*n)%10;
		cout << ans;
	}
	
}