2-Satisfiability (2-SAT) Problem in C/C++

Arnab Chakraborty
Updated on 29-Jan-2020 06:52:04

412 Views

Let f = (x1 ∨ y1) ∧ (x2 ∨ y2) ∧ ... ∧ (xn ∨ yn).Problem: Is f satisfiable?xi ∨ yi and and   are all equivalent. So we are converting each of (xi ∨ yi) s into those two statements.Now assume a graph with 2n vertices. In case of each of (xi∨yi) s two directed edges are addedFrom ¬xi to yiFrom ¬yi to xif is not treated as satisfiable if both ¬xi and xi are in the same SCC (Strongly Connected Component)Assume that f is treated as satisfiable. Now we want to provide values to each variable in order to satisfy ... Read More

Punctuation Character as Delimiter Between MySQL Date Parts

Prabhas
Updated on 29-Jan-2020 06:51:13

120 Views

In this matter, MySQL permits us to use a relaxed format to date. We can use any punctuation character between date parts as a delimiter. Some examples are as follows −mysql> Select date ('2016/10/20'); +---------------------+ | date ('2016/10/20') | +---------------------+ | 2016-10-20          | +---------------------+ 1 row in set (0.00 sec) mysql> Select date('2016^10^20'); +--------------------+ | date('2016^10^20') | +--------------------+ | 2016-10-20         | +--------------------+ 1 row in set (0.00 sec) mysql> Select date ('2016@10@20'); +---------------------+ | date ('2016@10@20') | +---------------------+ | 2016-10-20          | +---------------------+ 1 row in set (0.00 sec) mysql> Select date ('2016+10+20'); +---------------------+ | date ('2016+10+20') | +---------------------+ | 2016-10-20          | +---------------------+ 1 row in set (0.00 sec)

Delimiter Character for MySQL Time Parts

Krantik Chavan
Updated on 29-Jan-2020 06:50:19

115 Views

As in the case of date values, MySQL also permits us to use a relaxed format for time. We can use any punctuation character between time parts as a delimiter. Some examples are as follows −mysql> Select timestamp('2017-10-20 04+05+36'); +----------------------------------+ | timestamp('2017-10-20 04+05+36') | +----------------------------------+ | 2017-10-20 04:05:36              | +----------------------------------+ 1 row in set (0.00 sec) mysql> Select timestamp('2017-10-20 04*05*36'); +----------------------------------+ | timestamp('2017-10-20 04*05*36') | +----------------------------------+ | 2017-10-20 04:05:36              | +----------------------------------+ 1 row in set (0.00 sec) mysql> Select timestamp('2017-10&20 04@05+36'); +----------------------------------+ | timestamp('2017-10&20 ... Read More

Use Any Character for Space in MySQL TIMESTAMP

varun
Updated on 29-Jan-2020 06:49:22

153 Views

We can use the only character ‘T’ (in Capital form only) at the place of space between date and time part. It can be elucidated with the help of the following example −mysql> Select TIMESTAMP('2017-10-20T06:10:36'); +----------------------------------+ | TIMESTAMP('2017-10-20T06:10:36') | +----------------------------------+ | 2017-10-20 06:10:36              | +----------------------------------+ 1 row in set (0.00 sec)

MySQL Returns on Using Different Characters Between Date and Time Parts

usharani
Updated on 29-Jan-2020 06:48:45

96 Views

In that case, MySQL will return all zeros at the place of time along with correct date part. An example is as follows in which we used character ‘W’ at the place of ‘T’ or ‘Space’ between date and time part −mysql> Select TIMESTAMP('2017-10-20W06:10:36'); +----------------------------------+ | TIMESTAMP('2017-10-20W06:10:36') | +----------------------------------+ | 2017-10-20 00:00:00              | +----------------------------------+ 1 row in set, 1 warning (0.00 sec)

MySQL Interpretation of Number and String as Date

varma
Updated on 29-Jan-2020 06:48:06

269 Views

If a string or number, even without any delimiter, in the format of YYYYMMDDHHMMSS or YYMMDDHHMMSS is making sense as the date is provided then MySQL interpret that string as a valid date.Examples are given for valid as well as invalid dates −mysql> Select Timestamp(20171022040536); +---------------------------+ | Timestamp(20171022040536) | +---------------------------+ | 2017-10-22 04:05:36       | +---------------------------+ 1 row in set (0.00 sec) mysql> Select Timestamp('20171022040536'); +-----------------------------+ | Timestamp('20171022040536') | +-----------------------------+ | 2017-10-22 04:05:36         | +-----------------------------+ 1 row in set (0.00 sec) mysql> Select Timestamp('171022040536'); +---------------------------+ | Timestamp('171022040536') | +---------------------------+ | 2017-10-22 04:05:36   ... Read More

Digits Required for Date Value in MySQL

Sreemaha
Updated on 29-Jan-2020 06:43:57

161 Views

While considering the year as 4-digit value, minimum of 8 digits in a string or number is required for MySQL to specify it as a date value. In this case, if we also want to store microseconds then the value can be up to a maximum of 20 digits.mysql> Select TIMESTAMP('20171022040536.100000'); +-----------------------------------+ | TIMESTAMP('20171022040536100000') | +-----------------------------------+ | 2017-10-22 04:05:36.100000        | +-----------------------------------+ 1 row in set, 1 warning (0.00 sec)The query above is taking 20 digits string for TIMESTAMP value. Last 6 digits are for microseconds.mysql> Select TIMESTAMP(20171022); +---------------------+ | TIMESTAMP(20171022) | +---------------------+ | 2017-10-22 00:00:00 | +---------------------+ ... Read More

radialGradient HTML5 Tag

Lakshmi Srinivas
Updated on 29-Jan-2020 06:42:19

262 Views

The HTML5 tag is used to draw SVG Gradients. Yes, modern browsers support it.The following is the HTML5 version of an SVG example that would draw an ellipse using the tag and would use the tag to define an SVG radial gradient. Similar way you can use the tag to create SVG linear gradient.                    #svgelem{             position: relative;             left: 50%;             -webkit-transform: translateX(-40%);             -ms-transform: translateX(-40%);             transform: translateX(-40%);          }             SVG                     HTML5 SVG Gradient Ellipse                                                                              

Apply Gravity Between Objects in HTML5 Canvas

Nishtha Thakur
Updated on 29-Jan-2020 06:41:21

260 Views

To apply gravity between two or more object in Canvas:var distX = ob1.x - ob2.x, distY = ob1.y - ob2.y; var val = distX *distX + distY * distY; var r = Math.sqrt(val); var F = 50 / val; var rhat_x = distX / r; var rhat_y = distY / r; var Fx = F * rhat_x; var Fy = F * rhat_y; ob1.vx += -Fx; ob1.vy += -Fy; ob2.vx += Fx; ob2.vy += Fy;

Detect Area of a PNG That Is Not Transparent with HTML

Lakshmi Srinivas
Updated on 29-Jan-2020 06:40:56

533 Views

To detect an area of a PNG that is not transparent: You need to first get the buffer You need to get 32-bits reference of that buffer Scan 0 widths to find x1 edge Scan width 0 to find x2 edge Height to find the y1 edge Height 0 to find the y2 edge

Advertisements