Posts

Gray Code

আজকের প্রব্লেম এর নাম হচ্ছে গ্রে কোড (Gray Code) । এটা LeetCode  এর একটা প্রব্লেম

URI 2996 Solution

 URI 2996 - Package Delivery 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 SELECT year , sender, receiver FROM packages AS p INNER JOIN ( SELECT id_package, name AS sender FROM packages INNER JOIN users ON id_user_sender = id WHERE address <> 'Taiwan' ) AS sub1 ON sub1 . id_package = p . id_package INNER JOIN ( SELECT id_package, name AS receiver from packages INNER JOIN users ON id_user_receiver = id WHERE address <> 'Taiwan' ) AS sub2 ON sub2 . id_package = p . id_package WHERE color = 'blue' OR year = 2015 ORDER BY year DESC , sender DESC ;

Chicken McNugget Theorem

Image
Problem Post #01 Given a positive integer N, determine whether you can make N by summing up some non-negative multiple of A and some non-negative multiple of B where A and are relatively prime numbers. ( একটা ধনাত্বক পূর্নসংখ্যা N দেয়া আছে । তোমাকে বলতে হবে N কে A এবং B এর গুনিতক এর যোগফল আকারে প্রকাশ করা যায় কিনা ।  অর্থাৎ N = xA + yB আকারে প্রকাশ করা যায় কিনা যেখানে x এবং y রিলেটিভ প্রাইম সংখ্যা ।  ) Solutions: The Chicken McNugget Theorem (or Postage Stamp Problem or Frobenius Coin Problem) states that for any two relatively prime positive integers A, B, the greatest integer that cannot be written in the form xA + yB for nonnegative integers x, y is  AB - A - B. ( এই থিওরি মতে যেকোন দুইটা রিলেটিভ পজিটিভ প্রাইম সংখ্যা A এবং B এর জন্য সবচেয়ে বড় যে সংখ্যাটা xA + yB  ফর্ম এ লেখা যাবে না সেটা হলো A*B - A - B অর্থাৎ A*B - A - B  এর থেকে বড় সকল সংখ্যা  xA + yB আকারে প্রকাশ করা যাবে  ) A consequence of the theorem is that there are exactly  positive integers which cannot be expressed in th

URI 2993 Solution

URI 2993 - Most Frequent 1 2 3 4 5 6 SELECT amount FROM value_table GROUP BY amount ORDER BY COUNT(amount) DESC LIMIT 1 ;

URI 2994 Solution

URI 2994 - How much earn a Doctor?  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 SELECT d . name , ROUND (t . salary, 1 ) FROM doctors as d INNER JOIN ( SELECT id_doctor, SUM( (hours * 150 ) + ((hours* 150.0 * w . bonus) / 100.0 ) ) AS salary FROM work_shifts AS w INNER JOIN attendances AS a ON w . id = a . id_work_shift GROUP BY id_doctor ) AS t ON t . id_doctor = d . id ORDER BY t . salary desc ;

URI 2995 Solution

URI 2995 - The Sensor Message 1 2 3 4 SELECT temperature, COUNT(mark) AS number_of_records FROM records GROUP BY temperature, mark ORDER BY mark;

URI 2602 - Basic Select

URI 2602 - Basic Select 1 2 3 SELECT name FROM customers WHERE state = 'RS' ;