Demo entry 6762356

Johnson

   

Submitted by anonymous on Oct 13, 2018 at 04:15
Language: C++. Code size: 521 Bytes.

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int n, m, d;		
int Q(int i){		// 返回第i天剩下多少桃子 
	if( i==n ){
		return d;
	}
	return 2*Q(i+1)+2*m;
}

int main(int argc, char** argv) {
	
	while(cin >> n >> m >> d){		// 输入n, m, d   第n天还剩下d个桃子
		if(!n){
			break;
		}
		int res = Q(1);
		if(res <= 0){
			cout << "输入有误!" << endl;
		} else {
			cout << "第一天共摘了" << res << "个桃子." << endl;
		}
	}
	return 0;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).