现在的位置: 首页 > 综合 > 正文

Hackerrank Chocolate Feast

2018年10月29日 ⁄ 综合 ⁄ 共 262字 ⁄ 字号 评论关闭
#include <iostream>

using namespace std ;

int main()
{
	int t ;
	cin >> t ;
	while(t--)
	{
		int n , c , m ;
		cin >> n >> c >> m ;
		int t = n/c ;
		int w = t ;
		bool flag = true ;
		 while(flag)
		{
			if ( w >= m)  
			{
				t = t + 1 ;
				w = w-m+1;
				flag = true ;
			}
			else 
			{
				cout << t << endl ;
				flag = false ;
			}
		}
	}
	return 0 ;
}
https://www.hackerrank.com/challenges/chocolate-feast

抱歉!评论已关闭.