Posts

Dhaka Regional ACM ICPC 2016 Mock Contest Solution C - Stick to Triangle

C. Stick to Triangle Score: 1 CPU: 1s Memory: 1200MB You are given a stick of length N. You want to break it in three pieces such that it can form a triangle. In how many distinct triangles can you make? Two triangles are equal if all the side length is same when sorted in ascending order of length. So (1, 3, 2) is same to (3, 1, 2) because their side lengths are same is we sort them which is (1, 2, 3). But (1, 3, 4) is not same with (1, 2, 3). Suppose the lengths of three pieces are X, Y, Z respectively. Following constraints should be maintained: X, Y, Z > 0. X, Y, Z is an integer. X + Y + Z = N A triangle with zero area is considered a valid triangle. For example if N = 14, then there are 7 triangles: (1, 6, 7), (2, 5, 7), (2, 6, 6), (3, 4, 7), (3, 5, 6), (4, 4, 6), (4, 5, 5). Input First line will give you the number of test cases, T (T<=100). Then each line will have an integer N (0< N <= 300000). Output For each case print one line ...

Dhaka Regional ACM ICPC 2016 Mock Contest Solution B - Bus Stopage

B. Bus Stopage Score: 1 CPU: 1s Memory: 1200MB Bus service of Dhaka is life saving for many people. It’s the cheapest way of travel among the city, and it’s even cheaper for the students due to half fare. So many students ride the bus to go to their institutions (schools, colleges or universities). Government of Bangladesh wants this to be even cheaper for the students. That’s why they are starting a special bus service for school students. This bus service will start from the start of the city and will go to the end (I know it seems weird, but try to imaging Dhaka as a linear city). There are N stoppages among this route and in every stoppage few gets on the bus and few people gets off. This number is always fixed because students don’t change home or school that often. Now the authority has one problem and that is determining the size of the bus. The bus should be as big as that it can accommodate the students at every stoppage. Let’s see an example. Suppose there are 4 ...

Dhaka Regional ACM ICPC 2016 Mock Contest Solution A - A Piece of Cake

A. A Piece of Cake Score: 1 CPU: 1s Memory: 1200MB Okay, nothing to do with cakes really, whether you love them or not. This is to ascertain that this is a very very easy problem. So here is the deal, given an integer  n , print all integers from 0 to  n  in increasing order. The limit of  n ? Who gives a damn when the problem is so easy? :D Input Input begins with a positive integer  T , number of test cases.  T  lines follow, each containing a single integer,  n . Output For each test case produce a line containing single space separated values from 0 to  n  in ascending order. Sample Input Output 2 1 5 0 1 0 1 2 3 4 5

First Time Attending in ACM ICPC 2016 and Discuss with Solutions

Image
প্রথম বারের মত আজ ICPC 2016 করলাম। আগেই বলে নিচ্ছি এটা Preliminary করলাম। যেহেতু ফাস্ট টাইম। তাই আমি একটু বেশি ই এক্সাইটেড। ভালো কথা... ফাইনাল রাউন্ডে আমাদের গ্রুপ যাচ্ছে না! পারি নাই। সহজ বাংলায়... ভালো পারফর্মেন্স  করতে পারি নাই তাই ফাইনালের জন্য সিলেক্ট ও হই নাই। আশা রাখছি সামনে হবে ইনশা-আল্লাহ ICPC 2017 :D বড় ভাই এনারা। বড় বড় প্রবলেম সল্ভার। এমন পিক আবার তুলতে পারবো কি না কে জানে আমার টিমে ছিলো  ফাতিন ভাই  আর  মহসিনা । ফাতিন ভাই... সে তো এক কি বলবো। যেমন মজার মানুষ তেমনি সেই মাইন্ডের মানুষ। প্রবলেম গুলা অনেক তাড়াতাড়ি ক্যাপচার করে ফেলেন। আর মহসিনা? OMG!!! তার CGPA কত জানেন? 3.94 up. এতো তাড়াতাড়ি ম্যাথ গুলা ক্যালকুলেশন করে ফেলে যে আমি প্রবলেম টা পুরো পড়ে ও শেষ করতে পারি না। আমার কাজ হলো, তাদের থিংকিং গুলা কোডে রূপান্তরিত করা। ধরতে পারেন, আমি হইলাম একটা কম্পাইলার মেশিন। যা নাকি থিংকিং গুলাকে কোডে পরিণত করে :D  ফাতিন ভাই ১ বছরের সিনিয়র। আর মহসিনা আমার সেইম ব্যাচ। আমার ব্যাচ কত? আমি ২০০১ সালে ক্লাস ওয়ান এ পড়ছি :D Team: SEU_FMM একসাথে এতো গুলা বড়ভা...

Solution - Codeforces Problem 327B - Hungry Sequence

B. Hungry Sequence Iahub and Iahubina went to a date at a luxury restaurant. Everything went fine until paying for the food. Instead of money, the waiter wants Iahub to write a Hungry sequence consisting of  n  integers. A sequence  a 1 ,  a 2 , ...,  a n , consisting of  n  integers, is  Hungry  if and only if: Its elements are in increasing order. That is an inequality  a i  <  a j  holds for any two indices  i ,  j   ( i  <  j ) . For any two indices  i  and  j   ( i  <  j ) ,  a j  must  not  be divisible by  a i . Iahub is in trouble, so he asks you for help. Find a Hungry sequence with  n  elements. Input The input contains a single integer:  n  ( 1 ≤  n  ≤ 10 5 ). Output Output a line that contains  n  space-separated integers  a 1   a 2 , ...,  a n   (1 ≤  a i  ≤ 10 7 ) , representing a ...

Solution - Codeforces Problem 25A - IQ test

A. IQ test Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given  n  numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given  n  numbers finds one that is different in evenness. Input The first line contains integer  n  ( 3 ≤  n  ≤ 100 ) — amount of numbers in the task. The second line contains  n  space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness. Output Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order. Examples input 5 2 4 7 8 10 output 3 input 4 1 2 1 1 output 2 Click to view  Problem Online  সল্যুশন্সঃ #include<iostream> using namespace std; int main...

Solution - Codeforces Problem 703A - Mishka and Game

A. Mishka and Game Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game. Rules of the game are very simple: at first number of rounds  n  is defined. In every round each of the players throws a cubical dice with distinct numbers from  1  to  6  written on its faces. Player, whose value after throwing the dice is greater, wins the round. In case if player dice values are equal, no one of them is a winner. In average, player, who won most of the rounds, is the winner of the game. In case if two players won the same number of rounds, the result of the game is draw. Mishka is still very little and can't count wins and losses, so she asked you to watch their game and determine its result. Please help her! Input The first line of the input contains single inte...