60 likes | 151 Views
The SECOND Meeting. Or: How I learned exciting new things in CS Club. As you all know…. The best way to learn is to do. It’s true! Thus we will be giving you awesome problems to do They’re awesome! There’ll be one each week! Thus they’re called Problems of the Week! ( PotW )
E N D
The SECOND Meeting Or: How I learned exciting new things in CS Club
As you all know… • The best way to learn is to do. • It’s true! • Thus we will be giving you awesome problems to do • They’re awesome! • There’ll be one each week! • Thus they’re called Problems of the Week! (PotW) • Concepts and tricks for USACO and other contests! • Prizes!
The PotW Process* *subject to change • Problem presented at meeting • Will be posted online • Submit solutions to potw@lynbrookcs.com by 11:59PM the day before the next meeting • Feel free to give any feedback about difficulty • Or suggest your own problems • Solution presented at next meeting • Will be posted online after it’s presented • See how you and others are doing at lynbrookcs.com! • Prizes at end of semester!
The Problems • Any programming language accepted • Graded based on guidelines specified in problem • Officers reserve the right to grade as they please :] • Console input/output (System.in, System.out) unless otherwise specified • Java input: Use Scanner (easier) or BufferedReader (faster)
Reading Input in JAVA import java.io.*; importjava.util.*; Scanner s = newScanner(System.in); int n = s.nextInt(); BufferedReader r = newBufferedReader( newInputStreamReader(System.in)); intn = Integer.parseInt(r.readLine());
PotW #1: The Ninja Cow • Farmer John (get used to the cow theme) has quite a few cows, "conveniently" numbered 1 to N, inclusive. • Except, one day, one cow became a ninja and "disappeared" from the herd. Your job is to figure out which cow became a ninja. • To avoid arousing the suspicions of the ninja cow, you cannot use arrays, you cannot use longs, and you cannot allow integer overflow. • For 10 points, implement your solution for N = 3 • For 15 points, implement your solution for 2 ≤ N ≤ 1000 • For 20 points, implement your solution for 2 ≤ N ≤ 106 Sample Input:Sample Output: 4 (number of cows) 2 (ID of ninja cow) 3 (1st visible cow) 4 (2nd) 1 (etc.)