Submission
Status:
PPPPPPPPPP
Score: 100
User: admin
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.002 second
Submitted On: 2024-11-25 09:12:53
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n==1) {
// special case
cout << 1;
return 0;
}
int k = 0;
k+=n;
int C = 0;
int rnd = 0;
for (int i=n-1;i>1;i--) {
rnd++;
if (rnd%2 == 1) {
// left + down
k+=2*i;
k%=10;
C += k;
} else {
// right
C += (k+1)%10;
// up + right
k+=2*i;
}
}
// last two numbers always added
C += (k+1)%10;
C += (k+2)%10;
cout << C;
return 0;
}