<PREV Problem:
NEXT>
Solved by 23 users: Jenko, Rizvanov, Stefan.Bialucha, rvashegin, WsemirZ, tourist, wInuX, Zhukov_Dmitry, dan, zloy_mipt, mazahaka, MIKseR, ilyakor, defrager, RAVEman, EAA2008, ripatti, topspin, Dest, s01A06, JohnJones_001, Rinko, NIGHTFIT.
UserDateAttemptTimeCMSC
Rizvanov14 feb 2008C++200.02205 
topspin14 aug 2010Kylix600.11307 
tourist24 jul 2008FPC400.07337 
dan12 oct 2008C++600.15350 
rvashegin19 jul 2008C++100.38380 
RAVEman06 feb 2010C++100.02384 
JohnJones_00123 jul 2012C++900.24384 
wInuX26 aug 2008Java400.28387 
s01A0618 may 2011C2600.03395 
s01A0618 may 2011C1200.02413 
Dest19 feb 2011C++800.11429 
Languages
C++
12
Kylix
5
FPC
4
C
2
Java
1
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

Nuts

Time limit = 1 second(s)

In the very middle of the Hundred Acre Wood there is a huge oak. Squirrel Barbara lives in one of this oak's hollows. Each day she walks along the forest in a quite unusual way. She starts her walk near the oak, facing North, and in each unit of time she performs a move in the following way:

*) If there is a nut in her current location then she picks it up, turns 90 right and walks straight for 1 meter.

*) If there is no nut where Barbara is standing then she drops a nut in her current location, turns 90 left and also walks straight for 1 meter.

Your task is to count the number of nuts that are lying on the ground after t units of time.

Input

The first line of the input file contains one integer n (0<=n<=7), denoting the number of nuts that were lying on the ground at time 0. The following n lines describe the nuts' locations: each of them contains two integers x and y (-2<=x,y<=2), separated by a single space. Such line means that the nut lies x meters to the East and y meters to the South from the oak. You can assume that no two nuts lie in the same location. The last line of input contains one integer t (0<=t<=1000000000), denoting the number of units of time that passed since Barbara started her walk.

Output

The first and only line of the input file should contain one non-negative integer, denoting the number of nuts that are lying on the ground after t units of time. We assume that Barbara has an unlimited number of nuts.

Input#1
2
0 0
-2 1
8
Output#1
6

Author:
Tomasz Idziaszek (monsoon)

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 200ms

SW soft NIX
ID = 52.3.228.47