U E D R , A S I H C RSS

Jolly Jumpers/곽세환



히 해

~cpp 
#include <iostream>
using namespace std;

int main()
{
	int n;
	int input[3000];
	bool diff[3000];	//    크
			//  1 ~ n-1   
	int i;
	bool isJolly;
	while (cin >> n)
	{
		isJolly = true;
		for (i = 0; i < n; i++)
			cin >> input[i];
		if (n > 1)
		{
			for (i = 0; i < n; i++)
				diff[i] = false;
			for (i = 0; i < n - 1; i++)
				diff[abs(input[i] - input[i + 1])] = true;
			for (i = 1; i <= n - 1; i++)
				if (diff[i] == false)
				{
					isJolly = false;
					break;
				}
		}
		if (isJolly == true)
			cout << "Jolly\n";
		else
			cout << "Not jolly\n";
	}
	
	return 0;
}


n , ? --
... --

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:34
Processing time 0.0086 sec