Làm sao để có câu trả lời hay nhất?
20/06/2023
asdaaa
20/06/2023
20/06/2023
bạn tham khảo code tim hoặc của mình nè:
#include <iostream>
int main() {
int n, m;
std::cin >> n >> m;
int years = 0;
int balance = n;
while (balance < m) {
int interest = balance * 0.1; // Calculate the interest for the current year
balance += interest; // Add the interest to the balance
years++; // Increment the number of years
// Check if the balance is enough to buy cows
if (balance >= m) {
break;
}
}
std::cout << years << std::endl;
return 0;
}
Nếu bạn muốn hỏi bài tập
Các câu hỏi của bạn luôn được giải đáp dưới 10 phút
CÂU HỎI LIÊN QUAN
21/04/2025
Top thành viên trả lời