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

104/813

Solve/Submission

Ranking

# User Language Timing
01 habib_rahman Cpp14 0.00s
02 emotionless Cpp14 0.00s
03 mamun4122 Cpp14 0.00s
04 sahedsohel Cpp14 0.00s
05 tuxcoder Cpp14 0.00s
06 abid1 Cpp14 0.00s
07 MRoy Cpp14 0.00s
08 mahbubcseju Cpp14 0.00s
09 alamin39 Cpp14 0.00s
10 nasir_32_15 Cpp14 0.00s
11 rajdipsaha Cpp14 0.00s
12 dmehrab06 Cpp14 0.00s
13 SleepyBrain Cpp14 0.00s
14 nasif2587 Cpp14 0.00s
15 rezwanul502 Cpp14 0.00s
16 akazad_cse13_ruet Cpp14 0.00s
17 I_See_You Cpp14 0.00s
18 Puja1409 Cpp14 0.00s
19 Gang_Of_Three_01 Cpp14 0.00s
20 PKP_007 Cpp14 0.00s
21 sumon23 Cpp14 0.00s
22 sakib_ruet_13 Cpp14 0.00s
23 badhansen123 Cpp14 0.00s
24 shaft Cpp14 0.00s
25 subhashis_cse Cpp14 0.00s
26 KIRIN_36 Cpp14 0.00s
27 sayedgkm Cpp14 0.00s
28 ArifKhanShubro Cpp14 0.00s
29 aseem_cu Cpp14 0.00s
30 anikatahsin Cpp14 0.00s
31 zyyxxx Cpp14 0.00s
32 emrul Cpp14 0.00s
33 MsNahid Cpp14 0.00s
34 Knight_King Cpp14 0.00s
35 Santho07 Cpp14 0.00s
36 robincse14 Cpp14 0.00s
37 _zErO_ Cpp14 0.00s
38 ThunderStroke Cpp14 0.00s
39 anindita Cpp14 0.00s
40 sazal_dev Cpp14 0.00s
41 7Mahfuz Cpp14 0.00s
42 deder Cpp14 0.00s
43 rayhan50001 Cpp14 0.00s
44 Initiated Cpp14 0.00s
45 dip_BRUR Cpp14 0.00s
46 shaykhsiddique Cpp14 0.00s
47 pulak_ict_mbstu Cpp14 0.00s
48 moshiur_cse15 Cpp14 0.00s
49 Code_Hunter Cpp14 0.00s
50 SKL12 Cpp14 0.00s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support