习题2.3 old bill

描述
Among grandfather’s papers a bill was found. 72 turkeys $679 The first and the last digits of the number that obviously represented the total price of those turkeys are replaced here by blanks (denoted _), for they are faded and are illegible. What are the two faded digits and what was the price of one turkey? We want to write a program that solves a general version of the above problem. N turkeys $XYZ The total number of turkeys, N, is between 1 and 99, including both. The total price originally consisted of five digits, but we can see only the three digits in the middle. We assume that the first digit is nonzero, that the price of one turkeys is an integer number of dollars, and that all the turkeys cost the same price. Given N, X, Y, and Z, write a program that guesses the two faded digits and the original price. In case that there is more than one candidate for the original price, the output should be the most expensive one. That is, the program is to report the two faded digits and the maximum price per turkey for the turkeys.
输入描述:
The first line of the input file contains an integer N (0<N<100), which represents the number of turkeys. In the following line, there are the three decimal digits X, Y, and Z., separated by a space, of the original price $XYZ.
输出描述:
For each case, output the two faded digits and the maximum price per turkey for the turkeys.

#include <stdio.h>int main() {int n, x,y,z,price = 0,a,b;while (scanf("%d %d %d %d", &n, &x,&y,&z) != EOF) { }for(int i = 1;i < 10;i++)for(int j = 0;j < 10;j++){int t = i*10000+x*1000+y*100+z*10+j;if(t%n == 0 && t/n>price){a = i;b = j;price = t/n;}}if(price == 0)printf("0");elseprintf("%d %d %d",a,b,price);return 0;
}

暴力遍历即可

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/692155.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【力扣 - 二叉树的最大深度】

题目描述 给定一个二叉树 root &#xff0c;返回其最大深度。 二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。 提示&#xff1a; 树中节点的数量在 [0, 10^4] 区间内。 -100 < Node.val < 100方法一&#xff1a;深度优先搜索 思路与算法 如…

Rust中不可变变量与const有何区别?

Rust作者认为变量默认应该是immutable&#xff0c;即声明后不能被改变的变量。这一点是让跨语言学习者觉得很别扭&#xff0c;不过这一点小的改变带来了诸多好处&#xff0c;本节我们来学习Rust的变量。 什么是变量&#xff1f; 如果你初次学习编程语言&#xff0c;变量会是一…

使用go-llama.cpp 运行 yi-01-6b大模型,使用本地CPU运行,速度挺快的

1&#xff0c;视频地址 2&#xff0c;关于llama.cpp 项目 https://github.com/ggerganov/llama.cpp LaMA.cpp 项目是开发者 Georgi Gerganov 基于 Meta 释出的 LLaMA 模型&#xff08;简易 Python 代码示例&#xff09;手撸的纯 C/C 版本&#xff0c;用于模型推理。所谓推理…

手撕C语言习题

定义一个表示公交线路的结构体&#xff0c;要求有线路名称(例如 616)&#xff0c;起始站&#xff0c;终点站&#xff0c;里程等成员&#xff0c; 定义结构体数组&#xff0c;用来存储多条条公交线路信息&#xff0c;要求能够输出从指定起始站发车的所以公交线路信息。 2、定义…

【软考高项】【教材知识梳理】- 15 - 第15章 - 项目风险管理

一、基本问题 1&#xff1a;按照可预测性&#xff0c;风险分哪三类&#xff1f; &#xff08;1&#xff09;已知风险&#xff1a;如项目目标不明确&#xff0c; 过分乐观的进度计划&#xff0c; 设计或施工变更和材料价格波动等。&#xff08;2&#xff09;可预测风险&#xff…

NVIDIA Corporation 在 GitHub 的官方主页

NVIDIA Corporation 在 GitHub 的官方主页 References https://github.com/NVIDIA References [1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

力扣题目训练(17)

2024年2月10日力扣题目训练 2024年2月10日力扣题目训练551. 学生出勤记录 I557. 反转字符串中的单词 III559. N 叉树的最大深度241. 为运算表达式设计优先级260. 只出现一次的数字 III126. 单词接龙 II 2024年2月10日力扣题目训练 2024年2月10日第十七天编程训练&#xff0c;今…

Python系列(17)—— 位运算符

Python中的位运算符&#xff08;Bitwise Operator&#xff09; 一、引言 位运算符是直接对整数的二进制位进行操作的运算符。在Python中&#xff0c;位运算符可以对整数进行位级别的运算&#xff0c;如按位与&#xff08;AND&#xff09;、按位或&#xff08;OR&#xff09;、…

Mysql Day06

sql优化 插入数据 大批量插入数据 主键顺序插入性能高于乱序插入 load data local infile /root/load_user_100w_sort.sql into table tb_user fields terminated by , lines terminated by \n ; 主键优化 这个黄色的都是一个一个Page 主键乱序插入之后会变成1-3-2&#x…

qt - 19种精美软件样式

qt - 19种精美软件样式 一、效果演示二、核心程序三、下载链接 一、效果演示 二、核心程序 #include "mainwindow.h"#include <QtAdvancedStylesheet.h> #include <QmlStyleUrlInterceptor.h>#include "ui_mainwindow.h" #include <QDir&g…

从零开始学习Netty - 学习笔记 - NIO基础 - ByteBuffer: 简介和基本操作

NIO基础 1.三大组件 1.1. Channel & Buffer Channel 在Java NIO&#xff08;New I/O&#xff09;中&#xff0c;“Channel”&#xff08;通道&#xff09;是一个重要的概念&#xff0c;用于在非阻塞I/O操作中进行数据的传输。Java NIO提供了一种更为灵活和高效的I/O处理方…

基于微信小程序的日语学习的系统,附源码

博主介绍&#xff1a;✌程序员徐师兄、7年大厂程序员经历。全网粉丝12w、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精彩专栏推荐订阅&#x1f447;…

中台的介绍及讲解

什么是中台 公司在新的一年规划中提出了新的发展战略&#xff0c;我们老板听说最近中台的概念很火&#xff0c;让我们调研公司实习中台战略的可行性&#xff0c;于是乎最近一段时间被老板折腾得够呛。刚开始并不理解什么是中台… 因此&#xff0c;写篇博客先简单介绍下什么是中…

mp3播放器

无界面播放器 一、首先需要一个存放音乐文件的路径 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <glob.h> #include <signal.h>int menu(void); void fu…

24-k8s的附件组件-Metrics-server组件与hpa资源pod水平伸缩

一、概述 Metrics-Server组件目的&#xff1a;获取集群中pod、节点等负载信息&#xff1b; hpa资源目的&#xff1a;通过metrics-server获取的pod负载信息&#xff0c;自动伸缩创建pod&#xff1b; 参考链接&#xff1a; 资源指标管道 | Kubernetes https://github.com/kuberne…

Syntax error in cmake code when parsing string

CMake Error at D:\androidProjects\Android-mxxxx\app\src\main\jni\CMakeLists.txt:51 (add_library): Syntax error in cmake code when parsing string blog.csdnimg.cn/direct/794c8ba78dc747e99d200ca4b93e3450.png 解决办法&#xff0c;把路径的双斜杠改成单斜杠即可 D…

mysql中文首字母排序查询

MySQL中的排序涉及到字符集和排序规则。默认情况下&#xff0c;MySQL按照ASCII码对字符进行排序&#xff0c;数字>字母>中文。但是&#xff0c;特殊字符&#xff08;非字母、数字、中文&#xff09;的排序需要一些额外处理。 试过SUBSTRING、LEFT等&#xff0c;都不能完美…

静态时序分析:SDC约束命令set_input_delay详解

相关阅读 静态时序分析https://blog.csdn.net/weixin_45791458/category_12567571.html?spm1001.2014.3001.5482 本章将讨论使用set_input_delay命令对输入端口的约束。首先需要说明的是&#xff0c;在进行静态时序分析时&#xff0c;任何一条时序路径都需要有约束&#xff0…

如何使用安卓平板远程Ubuntu服务器通过VS Code远程开发

文章目录 1.ubuntu本地安装code-server2. 安装cpolar内网穿透3. 创建隧道映射本地端口4. 安卓平板测试访问5.固定域名公网地址6.结语 正文开始前给大家推荐个网站&#xff0c;前些天发现了一个巨牛的 人工智能学习网站&#xff0c; 通俗易懂&#xff0c;风趣幽默&#xff0c;…

【.NET Core】常见C#代码约定

【.NET Core】常见C#代码约定 文章目录 【.NET Core】常见C#代码约定一、概述二、代码预定的目标三、代码约束工具和分析器四、C#语言准则五、字符串约定5.1 使用字符串内插来连接短字符串5.2 插入大文本时&#xff0c;使用System.Text.StringBuilder对象 六、数组约定七、委托…