F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Celestial Being

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 236    Accepted Submission(s): 40


Problem Description
Celestial Being(CB) is a private military organization which is aimed to rid the wars and con icts in the world, using the advanced mobile suit gundam. But due to high cost of manufacture a gundam, only four gundams were produced, named Exia, Dynames, Kyrios and Virtue. Gundams use a kind of mysterious particles known as GN particle to communicate with each other, and GN particle always transport messages parallel to coordinate axises. Thus when in battle, four gundams always form a rectangle whose sides are parallel to x-axis or y-axis, and the coordinates of all gundams are integers. Have known celestial being is going to attack their military base, colonel of the enemy, Sergei Smirnov ordered to release some detectors to detect the positions of gundams when they arrive. The military base is a rectangle feld of with with corners (0, 0), (w, 0), (0, h) and (w, h). Each detector has a parameter d
and is either horizontal detector or vertical detector. A horizontal detector with parameter d can detect all positions on the lines y = h, where h is a multiple of d, while a vertical detector with parameter d can detect all positions on the lines x = v, where v is a multiple of d. If a position can be detected by k(k > 0) or more detectors, a gundam on that position will be discovered by the enemy. Got the parameters of all detectors from spy, the tactical forecaster of celestial being, Sumeragi Lee wants too know how many conservative battle positions are there. Can you help her? A
conservative battle position is a combination of four distinct points with integer coordinates, each stands for a position of one gundam such that no gundam can be detected by k or more detectors, and the four points form a rectangle whose sides parallel to x-axis or y-axis. Note that change the positions of two gundams will result in a new battle positon.
 

Input
Each test case begins with five integers w(1 <= w <= 108), h(1 <= h <= 108), m(0 <= m <= 20), n(0 <= n <= 20)
and k(k >= 1) on the first line, m is the number of horizontal detectors and n is the number of vertical
detectors. Then m + n lines follows, the first m line are the parameters of horizontal detectors, and the
rest n lines are the parameters of vertical detectors. All parameters are positive integers.
 

Output
Output one line for each test case, the number of conservative battle positions.
 

Sample Input
1 1 0 0 1 1 1 1 0 2 2 1 1 1 1 2 2 2 5 3 1 1 1 2 2 5 3 1 1 2 2 2 5 3 1 1 3 2 2
 

Sample Output
24 24 0 72 720 2160
 

Author
Cauchy (Special thanks WJH)
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-29 13:06:04, Gzip enabled