Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: KanemiyaKana

Problemset: ผลรวมตัวเลข

Language: cpp

Time: 0.003 second

Submitted On: 2026-09-23 17:19:27

#include <iostream>
#include <string>
using namespace std;

int conditionalfactorial(int start, int end)
{
    int total = 0;
    for (int i = start; i < end; i++)
    {
        if (i % 2 == 0)
        {
            total += i;
        }
        else if (i % 3 == 0)
        {
            total += i;
        }
    }

    return total;
}

int main()
{
    int input1;
    int input2;
    cin >> input1;
    cin >> input2;
    if (1 > input1 || input1 > 1000 || 1 > input2 || input2 > 1000)
    {
        return 0;
    }
    else if (input1 > input2)
    {
        return 0;
    }
    else
    {
        int output = conditionalfactorial(input1, input2);
        cout << output;
    }
}