#include <iostream> using namespace std; int main() { int count = 0; // 1 分硬币至少 1 枚,最多 93 枚(因为 2 分和 5 分硬币至少各 1 枚) for (int oneCent = 1; oneCent <= 93; oneCent++) { // 2 分硬币至少 1 枚,最多 47 枚(因为 1 分和 5 分硬币至少各 1 枚) for (int twoCent = 1; twoCent <= 47; twoCent++) { // 5 分硬币至少 1 枚,最多 19 枚(因为 1 分和 2 分硬币至少各 1 枚) for (int fiveCent = 1; fiveCent <= 19; fiveCent++) { // 检查总金额是否为 100 分 if (oneCent + twoCent * 2 + fiveCent * 5 == 100) { count++; } } } } cout << count << endl; return 0; } /************************************************************** Problem: 1025 User: fuyijun Language: C++ Result: Accepted Time:4 ms Memory:2072 kb ****************************************************************/