[ create a new paste ] login | about

Link: http://codepad.org/ZcO9HIZD    [ raw code | output | fork ]

C++, pasted on Jun 6:
#include<iostream>

const int num = 10;
const int divisor = 3;

int arr[num + 1] = { 0 };
int total = 0;
int ans = 0;


int main()
{
	for (int i = 1; i <= num; i++)
	{
		for (int j = i + 1; j <= num; j++)
		{
			for (int k = j + 1; k <= num; k++)
			{
				total++;
				
				int sum = i + j + k;
				if (sum % divisor == 0)
					ans++;
			}
		}
	}

	std::cout << total << std::endl << ans << std::endl;
	
	return 0;
}


Output:
1
2
120
42


Create a new paste based on this one


Comments: