PAT-A 1148 Werewolf - Simple Version (20)

  狼人杀简单版,暴力枚举

Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,

  • player #1 said: “Player #2 is a werewolf.”;
  • player #2 said: “Player #3 is a human.”;
  • player #3 said: “Player #4 is a werewolf.”;
  • player #4 said: “Player #5 is a human.”; and
  • player #5 said: “Player #4 is a human.”.

Given that there were 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. Can you point out the werewolves?

Now you are asked to solve a harder version of this problem: given that there were N players, with 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liars. You are supposed to point out the werewolves.

PAT-A 1081 Rational Sum (20)

  记录一次被水题的测试点教做人的经历,果然还是差得远。

Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.

使用分支限界法解决0/1背包问题

  在算法分析课上第一次接触分支限界法(Branch & Bound),实验要求使用分支限界法解决 0/1 背包问题。虽然很清楚代码量要远高于 DP,但报告是还要写的,硬着头皮怼吧。随便在蓝桥杯题库找了一道 0/1 背包的基础题做测试,题目是算法训练的 ALGO-30 入学考试。

设计模式 - 工厂模式(Factory Pattern)

  Java设计模式 - 工厂模式

N皇后(N-Queens)

  • LeetCode 51 N-Queens
  • LeetCode 52 N-Queens II
  • Lanqiao BASIC-27 2N-Queens
  • Lanqiao ADV-203 8-Queens
  • PAT-A 1128 N-Queens Puzzle
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×