DCP-219: Write an algorithm Back to All Problems

Medium Beginners Problems > Ad-hoc


Topu is a student of Computer Science & Engineering. And recently he taken a course of 3 credits named Algorithm Design & Analysis. He is so much interested for writing new algorithms with new techniques. Recently he invented some new techniques for writing pseudo-code. His techniques is designed for four types of operation. First one is: '**+**' Second one is: '**-**' Third one is: '*****' Fourth one is: '**/**' The pseudo-code for these operation is given below with examples: 4+3 -> "**add 4 to 3**" 4-3 -> "**subtract 3 from 4**" 4*3 -> "**multiply 4 with 3**" 4/3 -> "**divide 4 by 3**" **Note:** If any steps repeat then the output will be "**repeat step x**". where x is the step number when **the instruction was written** Don't count the repeated instructions as a new step. Be careful about some instructions like **4+3 & 3+4 is a same type of instruction** because they both creates same result 7. Although 5+2 is not considered same which also creates the same result 7. Also, **4*3 and 3*4 are considered same instruction**. Input: ------ There will be multiple cases upto EOF. Input starts with an integer **N (1<=N<=20)**, denoting the number of instructions set. Each case contains two integers **x** & **y** with any of the four operation which mentioned above. **(0<=x,y<=9)** Output: ------- For each case of input there should be one line of output with a case number like ("**Instruction x:** " where x denotes the instruction number) and the pseudo-code of the operation followed by a new line. For more clarification please see the simple input and output. Sample Input ------------ 5 4+3 4*3 4/3 4-3 4/3 1 4+3 Sample Output ------------- Instruction 1: add 4 to 3 Instruction 2: multiply 4 with 3 Instruction 3: divide 4 by 3 Instruction 4: subtract 3 from 4 Instruction 5: repeat step 3 Instruction 1: add 4 to 3


Problem Setter:

Mir Lutfur Rahman

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

105/815

Solve/Submission

Ranking

# User Language Timing
01 MRoy Cpp14 0.00s
02 emotionless Cpp14 0.00s
03 akazad_cse13_ruet Cpp14 0.00s
04 sayedgkm Cpp14 0.00s
05 I_See_You Cpp14 0.00s
06 habib_rahman Cpp14 0.00s
07 trifiasco Cpp14 0.00s
08 mamun4122 Cpp14 0.00s
09 Knight_King Cpp14 0.00s
10 sahedsohel Cpp14 0.00s
11 seyedssz Cpp14 0.00s
12 SleepyBrain Cpp14 0.00s
13 ThunderStroke Cpp14 0.00s
14 nasif2587 Cpp14 0.00s
15 tuxcoder Cpp14 0.00s
16 PKP_007 Cpp14 0.00s
17 pulak_ict_mbstu Cpp14 0.00s
18 anindita Cpp14 0.00s
19 mahbubcseju Cpp14 0.00s
20 pentagon9 Cpp14 0.00s
21 nasir_32_15 Cpp14 0.00s
22 Maruf_75 Cpp14 0.00s
23 rajdipsaha Cpp14 0.00s
24 dip_BRUR Cpp14 0.00s
25 Santho07 Cpp14 0.00s
26 moshiur_cse15 Cpp14 0.00s
27 kissu_pari_na Cpp14 0.00s
28 snow_man Cpp14 0.00s
29 dmehrab06 Cpp14 0.00s
30 saurabh3240 Cpp14 0.00s
31 sadiq_nayeem Cpp14 0.00s
32 abid1 Cpp14 0.00s
33 mukhter2 Cpp14 0.00s
34 Gang_Of_Three_01 Cpp14 0.00s
35 aseem_cu Cpp14 0.00s
36 forkkr Cpp14 0.00s
37 rayhan50001 Cpp14 0.00s
38 rezwanul502 Cpp14 0.00s
39 emrul Cpp14 0.00s
40 subhashis_cse Cpp14 0.00s
41 ashraful_haque Cpp14 0.00s
42 Code_Hunter Cpp14 0.00s
43 _zErO_ Cpp14 0.00s
44 sakib_ruet_13 Cpp14 0.00s
45 badhansen123 Cpp14 0.00s
46 sumon23 Cpp14 0.00s
47 ____ Cpp14 0.00s
48 ArifKhanShubro Cpp14 0.00s
49 Puja1409 Cpp14 0.00s
50 Dayamoy Cpp14 0.00s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support