Tags » Chapter 1

It was just one busy day of the many during the past seventeen years. I

woke up as usual and had the morning meeting with the chefs in one of… 1,042 more words

Chapter 1

The Ages of Empire

Soon after my growth in the Segstu justu, i encountered something marvelous…a gateway at the entrace of the church… I passed through this portal and found myself in 965 AD. 817 more words

Chapter 1

The beginning....

I woke up, late, again. I rubbed my eyes and quickly sat up. The clock glared at me: 7:15. I sighed and looked down at the sleeping man in my bed.   738 more words

Erotica

1.1.3

Prove that addition of residue classes in is associative.

Dummit And Foote

1.1.2

Determine which of the binary operations are commutative.

(a) the operation on defined by .

Consider when and . Then while so . Hence this operation is not commutative. 53 more words

Dummit And Foote

11221 - Magic square palindromes

Problem Statement

Simple simulation problem, do as told.

using namespace std;

const char SPACE = ' ';
const int N = 100;

struct io {
	template<class T> static inline T next() {
		T x; std::cin >> x;
		return x;
	}

	static inline std::string next_line(bool ignore = true) {
		if (ignore) std::cin.ignore();
		std::string s; std::getline(std::cin, s);
		return s;
	}
};

static void purify_sentence(string& str) {
	for (int i = 0; i < str.length(); ++i)
		if (!isalpha(str[i]))
			str.erase(str.begin() + i--);
}

static bool is_square(const int n) {
	const int root = (int) sqrt(n);
	return root * root == n;
}

static bool is_magic(const string& s, char grid[][N]) {
	const int power = (int) sqrt(s.length());

	int index = 0;
	for (int i = 0; i < power; ++i)
		for (int j = 0; j < power; ++j)
			grid[i][j] = s;

	index = 0;
	for (int a1 = 0, a2 = power - 1; a1 < power; ++a1, --a2)
		for (int b1 = 0, b2 = power - 1; b1 < power; ++b1, --b2) {
			const char ch = s;
			if (grid != ch || grid != ch || grid != ch || grid != ch)
				return false;
		}

	return true;
}

int main(int argc, char** args) {
	int T = io::next<int>();
	cin.ignore();

	char grid[N][N];
	for (int t = 1; T-- > 0; ++t) {
		string sentence = io::next_line(false);
		purify_sentence(sentence);
		
		const int n = sentence.length();

		cout << "Case #" << t << ":" << endl;
		if (is_square(n) && is_magic(sentence, grid))
			cout << (int) sqrt(n) << endl;
		else
			cout << "No magic :(" << endl;
	}
    return 0;
}
Chapter 1

Positives: Chapter 1

Anyone would love to get out of school. Having to not see enemy faces anymore and the boring wrinkles on your teacher’s foreheads. But getting out of school wasn’t easy, it wasn’t even intentional. 860 more words

New!