Submission
Status:
-P-P-P-P-P
Subtask/Task Score:
50/100
Score: 50
User: theem1502
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.010 second
Submitted On: 2026-02-15 11:12:07
#include <bits/stdc++.h>
using namespace std;
int main() {
long long num;
cin >> num;
long long sum = 0;
long long counter = 1;
long long thenum = 1;
if (num % 2 == 0) {
while(thenum < num * num) {
// cout << "num = " <<sum << "\n";
//thenum += (num - (counter-1) * 2) - 1;
// thenum++;
long long a = num - (counter - 1) * 2;
long long b = num - counter * 2;
thenum += a;
if (thenum > num * num) {
break;
}
if ((counter == num / 2 && num % 2 ==0) || (counter == num / 2 + 1 && num % 2 == 1)) {
// cout << "f";
sum += thenum % 10;
// cout << "thenum " << thenum << "\n";
// cout << "aded " << thenum % 10;
}
thenum += a - 1;
/*
if (counter == num / 2) {
cout << "f";
sum += thenum % 10;
cout << "tthenum " << thenum << "\n";
cout << "added " << thenum % 10;
}
*/
thenum += b;
// thenum += (num - (counter-1) * 2) - 1;
if (thenum > num * num) {
break;
}
/*
if (counter == num / 2) {
cout << "n";
sum += thenum % 10;
}
*/
//thenum + num - counter * 2;
// thenum += 2*(num - (counter - 1) * 2) - 1 + num - counter * 2;
if (thenum > num * num) {
break;
}
// cout << "first " << thenum << " ";
sum += thenum % 10;
thenum++;
if (thenum > num * num) {
break;
}
sum += thenum % 10;
thenum += num - (counter * 2);
if (thenum > num * num) {
break;
}
// cout << "second " << thenum << " ";
counter++;
}
}
if (num % 2 == 1) {
while(thenum < num * num) {
// cout << "num = " <<sum << "\n";
//thenum += (num - (counter-1) * 2) - 1;
// thenum++;
long long a = num - (counter - 1) * 2;
long long b = num - counter * 2;
thenum += a;
if (thenum > num * num) {
break;
}
if ((counter == num / 2 && num % 2 ==0) || (counter == num / 2 + 1 && num % 2 == 1)) {
// cout << "f";
sum += thenum % 10;
// cout << "thenum " << thenum << "\n";
// cout << "aded " << thenum % 10;
}
thenum += a - 1;
//cout << "yes";
if (num - counter - b < 2) {
cout << "yes";
for (long long i = 1; i < num + 1; i++) {
cout<< "debug " << thenum + i << "\n";
sum += thenum + i;
}
break;
}
/*
if (counter == num / 2) {
cout << "f";
sum += thenum % 10;
cout << "tthenum " << thenum << "\n";
cout << "added " << thenum % 10;
}
*/
thenum += b;
// thenum += (num - (counter-1) * 2) - 1;
if (thenum > num * num) {
break;
}
/*
if (counter == num / 2) {
cout << "n";
sum += thenum % 10;
}
*/
//thenum + num - counter * 2;
// thenum += 2*(num - (counter - 1) * 2) - 1 + num - counter * 2;
if (thenum > num * num) {
break;
}
// cout << "first " << thenum << " ";
sum += thenum % 10;
thenum++;
if (thenum > num * num) {
break;
}
sum += thenum % 10;
thenum += num - (counter * 2);
if (thenum > num * num) {
break;
}
// cout << "second " << thenum << " ";
counter++;
}
}
if (num == 1) {
cout << 1;
return 0;
}
cout << sum;
}