Submission
Status:
PPPPPPP-P-
Subtask/Task Score:
80/100
Score: 80
User: qweqwe
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-21 09:50:36
#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;
int n;cin >> n;
if (n==1){
cout << 1;return 0;
}
if (n==2){
cout << 7;return 0;
}int i=2;
int 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;
}