<p>Seven different symbols represent Roman numerals with the following values:</p>

<table>
	<thead>
		<tr>
			<th>Symbol</th>
			<th>Value</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>I</td>
			<td>1</td>
		</tr>
		<tr>
			<td>V</td>
			<td>5</td>
		</tr>
		<tr>
			<td>X</td>
			<td>10</td>
		</tr>
		<tr>
			<td>L</td>
			<td>50</td>
		</tr>
		<tr>
			<td>C</td>
			<td>100</td>
		</tr>
		<tr>
			<td>D</td>
			<td>500</td>
		</tr>
		<tr>
			<td>M</td>
			<td>1000</td>
		</tr>
	</tbody>
</table>

<p>Roman numerals are formed by appending&nbsp;the conversions of&nbsp;decimal place values&nbsp;from highest to lowest. Converting a decimal place value into a Roman numeral has the following rules:</p>

<ul>
	<li>If the value does not start with 4 or&nbsp;9, select the symbol of the maximal value that can be subtracted from the input, append that symbol to the result, subtract its value, and convert the remainder to a Roman numeral.</li>
	<li>If the value starts with 4 or 9 use the&nbsp;<strong>subtractive form</strong>&nbsp;representing&nbsp;one symbol subtracted from the following symbol, for example,&nbsp;4 is 1 (<code>I</code>) less than 5 (<code>V</code>): <code>IV</code>&nbsp;and 9 is 1 (<code>I</code>) less than 10 (<code>X</code>): <code>IX</code>.&nbsp;Only the following subtractive forms are used: 4 (<code>IV</code>), 9 (<code>IX</code>),&nbsp;40 (<code>XL</code>), 90 (<code>XC</code>), 400 (<code>CD</code>) and 900 (<code>CM</code>).</li>
	<li>Only powers of 10 (<code>I</code>, <code>X</code>, <code>C</code>, <code>M</code>) can be appended consecutively at most 3 times to represent multiples of 10. You cannot append 5&nbsp;(<code>V</code>), 50 (<code>L</code>), or 500 (<code>D</code>) multiple times. If you need to append a symbol&nbsp;4 times&nbsp;use the <strong>subtractive form</strong>.</li>
</ul>

<p>Given an integer, convert it to a Roman numeral.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num = 3749</span></p>

<p><strong>Output:</strong> <span class="example-io">&quot;MMMDCCXLIX&quot;</span></p>

<p><strong>Explanation:</strong></p>

<pre>
3000 = MMM as 1000 (M) + 1000 (M) + 1000 (M)
 700 = DCC as 500 (D) + 100 (C) + 100 (C)
  40 = XL as 10 (X) less of 50 (L)
   9 = IX as 1 (I) less of 10 (X)
Note: 49 is not 1 (I) less of 50 (L) because the conversion is based on decimal places
</pre>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num = 58</span></p>

<p><strong>Output:</strong> <span class="example-io">&quot;LVIII&quot;</span></p>

<p><strong>Explanation:</strong></p>

<pre>
50 = L
 8 = VIII
</pre>
</div>

<p><strong class="example">Example 3:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">num = 1994</span></p>

<p><strong>Output:</strong> <span class="example-io">&quot;MCMXCIV&quot;</span></p>

<p><strong>Explanation:</strong></p>

<pre>
1000 = M
 900 = CM
  90 = XC
   4 = IV
</pre>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= num &lt;= 3999</code></li>
</ul>

class Solution {
public:
    string conv(int n) {
        if (n>=1000) {
            switch(n){
                case 1000:
                return "M";
                break;
                case 2000:
                return "MM";
                break;
                case 3000:
                return "MMM";
                break;
            }
        }

        else if(n<1000&&n>=100){
            switch(n){
                case 100:
                return "C";
                break;
                case 200:
                return "CC";
                break;
                case 300:
                return "CCC";
                break;
                case 400:
                return "CD";
                break;
                case 500:
                return "D";
                break;
                case 600:
                return "DC";
                break;
                case 700:
                return "DCC";
                break;
                case 800:
                return "DCCC";
                break;
                case 900:
                return "CM";
                break;
            }
        }

        else if(n<100&&n>=10){
            switch(n){
                case 10:
                return "X";
                break;
                case 20:
                return "XX";
                break;
                case 30:
                return "XXX";
                break;
                case 40:
                return "XL";
                break;
                case 50:
                return "L";
                break;
                case 60:
                return "LX";
                break;
                case 70:
                return "LXX";
                break;
                case 80:
                return "LXXX";
                break;
                case 90:
                return "XC";
                break;
            }
        }

        else{
            switch(n){
                case 1:
                return "I";
                break;
                case 2:
                return "II";
                break;
                case 3:
                return "III";
                break;
                case 4:
                return "IV";
                break;
                case 5:
                return "V";
                break;
                case 6:
                return "VI";
                break;
                case 7:
                return "VII";
                break;
                case 8:
                return "VIII";
                break;
                case 9:
                return "IX";
                break;
            }
        }
        return "";
    }

    string intToRoman(int num) {
        string ans;
        int u = 0, t = 0, h = 0, th = 0;
        if (num >= 1000) {
            u = num % 10;         
            num /= 10;
            t = num % 10;           
            num /= 10;
            h = num % 10;
            num /= 10;
            ans += conv(num * 1000);
            ans += conv(h * 100);
            ans += conv(t * 10);
            ans += conv(u);           
        }

        else if (num < 1000 && num >= 100) {
            u = num % 10;
            num /= 10;
            t = num % 10;   
            num /= 10;
            ans += conv(num * 100);
            ans += conv(t * 10);
            ans += conv(u); 
        } else if (num < 100 && num >= 10) {
            u = num % 10;           
            num /= 10;
            ans += conv(num * 10);
            ans += conv(u);
        } else {
            ans += conv(num);
        }
        return ans;
    }
};
11071