Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: NovemNotes
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-11 13:55:45
#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{
int idx = (n-2)/2;
int range = 5+8*(idx-1);
while(range){
ans+=ok(st);st++;
ans+=ok(st);
st = ok(st+range);
if(range==5)break;
range-=8;
}
ans+=ok(st);
st = ok(st-1+10);
ans+=ok(st);
}
cout << ans << "\n";
return 0;
}