U E D R , A S I H C RSS

Jolly Jumpers/곽세환

JollyJumpers 문제풀�

소�

문제�해� 많� 시간� 걸림
�어공부를 열심히 해야겠다

소스

~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.0060 sec