Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: qweqwe

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

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-21 09:53:48

#include <bits/stdc++.h>
#define speed cin.tie(0)->sync_with_stdio(0)
#define ll long long
#define pii pair<int,int>
using namespace std;

int main(){
	speed;
	ll n;cin >> n;
	if (n==0){
		cout << 0;return 0;
	}
	if (n==1){
		cout << 1;return 0;
	}
	if (n==2){
		cout << 7;return 0;
	}int i=2;
	ll sum=(3*n-2)%10+(3*n-1)%10;
	ll temp=3*n-1;
	int j=0;
	while(i<n){
		if (temp==n*n)temp--;
		else if (i%2==0){
			temp=(temp+((n-3)*4+1)-8*j);
			j++;
		}else if (i%2==1) temp++;
		sum+=temp%10;
		//cout << temp << " " << sum << "\n";
		i++;
	}cout << sum;
	return 0;
}