View Code of Problem 118

#include <bits/stdc++.h>
using namespace std;
#define N 1.5
int main()
{
	int n,k=0;
	while(cin>>n) {
		k++;
		float sum;
		int flag=0;
		int m=0;
		while(n>0) {
			if(flag==0) {
				flag=1;
				sum=5;
				n-=3;	
			} else {
				sum+=1.5;
				m++;
				n--;
			}
		}
		if(m%2!=0) sum+=0.5; 
		cout<<"Case #"<<k<<": "<<sum<<endl; 
	}
	return 0;
 } 

Double click to view unformatted code.


Back to problem 118