Timus 1796. Amusement Park 聪明题

On a sunny Sunday, a group of children headed by their teacher came to an amusement park. Aunt Frosya, who was a very kind and quiet person, worked at the ticket window on that day. The teacher gave her the money but didn't say how many tickets she wanted to buy. Could Aunt Frosya determine it knowing only the numbers of different notes the teacher gave? It is assumed that the teacher didn't give extra notes, which means that there would not be enough money for the tickets if any of the notes was taken away.

Input

The first line contains six nonnegative integers separated with a space; these are the numbers of 10, 50, 100, 500, 1000, and 5000 rouble notes the teacher gave to Aunt Frosya. In the second line you are given the price of one ticket; it is a positive integer. All the integers in the input data do not exceed 1000.

Output

Find the number of tickets the teacher wanted to buy. Output the number of possible answers in the first line. The variants in ascending order separated with a space must be given in the second line. It is guaranteed that there is at least one variant of the answer.

Samples

input output
0 2 0 0 0 0
10
5
6 7 8 9 10
1 2 0 0 0 0
10
1
11


这是一道考人是否聪明的题目,没有现成的算法。

所以需要模拟人计算的过程,用计算机的程序思维去思考。

过程这样的:

1 先算出总钱数能购买多少张票

2 总钱数减去一张最小面值的钱,然后模票价,然后加上最小面值的钱,在减去一张票价,最后就得到灵活度的钱

3 灵活度的钱除以票价,就得到灵活度了,灵活度的钱除以票价得到零,那么就只有一种可能了,得到1就有两种可能

难以理解的话,就细心想想人是如何计算的就可以解决了。

#include <iostream>
using namespace std;

static const int AmusePartRoubles[6] = {10, 50, 100, 500, 1000, 5000};

void AmusementPark1796()
{
	int A[6] = {0};
	int money = 0;
	for (int i = 0; i < 6; i++)
	{
		cin>>A[i];
		money += A[i] * AmusePartRoubles[i];
	}
	int ticket = 0;
	cin>>ticket;
	int total = money / ticket;

	int i = 0;
	for ( ; i < 6 && A[i] == 0; i++);

	int leftMoney = (money - AmusePartRoubles[i]) % ticket;
	leftMoney += AmusePartRoubles[i] - ticket;
	int flex = leftMoney / ticket;

	cout<<flex+1<<endl;
	for (int j = flex; j >= 0 ; j--)
	{
		cout<<total - j<<' ';
	}
}

int main()
{
	AmusementPark1796();
	return 0;
}



1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
好的,以下是一份简单的游乐场Java项目: ```java import java.util.Scanner; public class AmusementPark { private static int balance = 0; private static int tickets = 0; private static int rides = 0; public static void main(String[] args) { Scanner input = new Scanner(System.in); int choice; do { System.out.println("\nWelcome to the Amusement Park!"); System.out.println("1. Buy tickets"); System.out.println("2. Check balance"); System.out.println("3. Ride a ride"); System.out.println("4. Exit"); System.out.print("Enter your choice: "); choice = input.nextInt(); switch(choice) { case 1: buyTickets(); break; case 2: checkBalance(); break; case 3: rideRide(); break; case 4: System.out.println("\nThank you for visiting the Amusement Park!"); break; default: System.out.println("\nInvalid choice! Please try again."); break; } } while(choice != 4); input.close(); } public static void buyTickets() { Scanner input = new Scanner(System.in); int amount; System.out.print("\nEnter the amount of tickets you want to buy: "); amount = input.nextInt(); balance += (amount * 10); // Each ticket costs $10 tickets += amount; System.out.println("You bought " + amount + " tickets, and your balance is now $" + balance + "."); input.close(); } public static void checkBalance() { System.out.println("\nYour balance is $" + balance + " and you have " + tickets + " tickets."); } public static void rideRide() { Scanner input = new Scanner(System.in); if(tickets > 0) { System.out.println("\nYou have " + tickets + " tickets. Which ride would you like to go on?"); System.out.println("1. Ferris wheel"); System.out.println("2. Roller coaster"); System.out.print("Enter your choice: "); int choice = input.nextInt(); switch(choice) { case 1: System.out.println("\nEnjoy your ride on the Ferris wheel!"); break; case 2: System.out.println("\nEnjoy your ride on the Roller coaster!"); break; default: System.out.println("\nInvalid choice! Please try again."); break; } tickets--; rides++; } else { System.out.println("You don't have enough tickets to ride any rides. Please buy more tickets."); } input.close(); } } ``` 这个游乐场项目有以下功能: 1. 购买门票:每张门票10美元,购买门票后,余额会相应增加。 2. 检查余额:显示当前余额和拥有的门票数量。 3. 玩游乐设施:如果有门票,可以选择想要坐的游乐设施,并扣除一张门票。如果没有门票,需要购买更多门票。 4. 退出游戏。 这只是一个简单的示例项目,您可以根据自己的需求进行修改和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值