Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: mantaggez
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-22 18:40:37
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin >> n;
// vector<ll> res;
ll i = 0, j = 0, ans = 0;
while(i < n * n)
{
ll a = max(0LL, n - j);
ll b = max(0LL, n - j - 2);
i += (2 * a + b);
// cout << i << '\n';
if(i > n * n) {
ans += ((i - 1) % 10);
// res.push_back((i - 1) % 10);
break;
}
if(i == n * n) {
ans += (i % 10) + ((i - 1) % 10);
// res.push_back(i % 10);
// res.push_back((i - 1) % 10);
break;
}
ans += (i % 10) + ((i + 1) % 10);
// res.push_back(i % 10);
// res.push_back((i + 1) % 10);
i += b;
j += 2;
}
// for(ll it : res) cout << "res : " << it << '\n'; cout << '\n';
cout << ans << '\n';
return 0;
}