Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: exoworldgd

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

Language: cpp

Time: 0.002 second

Submitted On: 2025-11-08 16:04:17

#pragma GCC optimize("O5,unroll-loops,inline")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#define exoworldgd cin.tie(0)->sync_with_stdio(0), cout.tie(0)
#define int long long
using namespace std;
const int inf = LLONG_MAX, mod = 1e9+7, maxn = 2e7+5;
signed main(void) {
	exoworldgd;
	int n;
	cin >> n;
	if (!n){cout << 0;return 0;}
	if (n==1){cout << 1;return 0;}
	if (n==2){cout << 7;return 0;}
	int j=0,sum=(3*n-2)%10+(3*n-1)%10,t=3*n-1,add;
	for (int i=2; i<n; i++) i == n-1 ? t += (n&1 ? 1 : -1) : (i&1 ? t++ : (add = (n-3)*4+1-8*j, t += add, j++)), sum += t%10;
	cout << sum;
}