344 – Roman Digititis

Problem Link

#Source Code

#include<bits/stdc++.h>

using namespace std;

int main()
{
int n,i,v,x,c,l,totali,totall,totalv,totalx,totalc;
fstream file;
file.open(“input.txt”);
while(cin>>n && n){
i=v=x=l=totali=totalv=totall=totalx=totalc=0;

for(int j=1;j<=n;j++)
{
switch(j/10)
{
case 1:
totalx+=1;
break;
case 2:

totalx+=2;
break;
case 3:

totalx+=3;
break;
case 4:
case 6:
totalx+=1,totall+=1;
break;
case 5:

totall+=1;
break;
case 7:
totall+=1,totalx+=2;
break;
case 8:
totall+=1,totalx+=3;
break;
case 9:
totalx++;
break;

}
switch(j%10)
{
case 0:
continue;
case 1:
totali+=1;
break;
case 2:

totali+=2;
break;
case 3:

totali+=3;
break;
case 4:
case 6:
totali+=1,totalv+=1;
break;
case 5:

totalv+=1;
break;
case 7:
totalv+=1,totali+=2;
break;
case 8:
totalv+=1,totali+=3;
break;
case 9:
totalx+=1,totali++;
break;

}

}
if(n>=90)
{
totalc+=1+(n%10)+(n>=100?n/10:0);

}
printf(“%d: %d i, %d v, %d x, %d l, %d c\n”,n,totali,totalv,totalx,totall,totalc);
}
return 0;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s