九度oj-1036-Old Bill

2024-06-10 14:18
文章标签 oj old bill 九度 1036

本文主要是介绍九度oj-1036-Old Bill,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:2697

解决:1437

题目描述:

    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.

样例输入:
72
6 7 9
5
2 3 7
78
0 0 5
样例输出:
3 2 511
9 5 18475
0
来源:
2007年上海交通大学计算机研究生机试真题

#include<iostream>
using namespace std;
int main()
{int n,x,y,z,i,j,t;while(cin>>n>>x>>y>>z){bool flag;for(i=9;i>0;i--){flag=false;for(j=9;j>=0;j--){t=i*10000+x*1000+y*100+z*10+j;if(t%n==0){flag=true;cout<<i<<" "<<j<<" "<<t/n<<endl;break;}}if(flag) break;}if(! flag)cout<<'0'<<endl;}return 0;
}


这篇关于九度oj-1036-Old Bill的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1048396

相关文章

九度1077(最大序列和)

题目链接:点击打开链接 解题思路: 很经典的一道题。首先考虑一下细节问题,当序列都是0时,显然最后要输出0;当序列都是负数时,显然要输出最大的数。 细节处理完了,就可以回到正常轨道。我们开两个变量,分别保存当前的序列和与之前的最大值,我们更新当前序列和的条件是如果当前序列和是负数的时候,那我们必须更新,否则一定会使最后结果减小。更新过程中还要更新之前最大值即可。 完整代码:

哈理工OJ 2179(深搜)

组合 Time Limit: 1000 MSMemory Limit: 32768 K Total Submit: 7(5 users)Total Accepted: 6(5 users)Rating: Special Judge: No Description 给出一个正整数N,从集合{1,2,3..N} 中找出所有大小为k的子集, 并按照字典序从小到大输出。 Input 第一行是一个整

每日OJ_牛客_求和(递归深搜)

目录 牛客_求和(递归深搜) 解析代码 牛客_求和(递归深搜) 求和_好未来笔试题_牛客网 解析代码         递归中每次累加一个新的数,如果累加和大于等于目标,结束递归。此时如果累加和正好等于目标,则打印组合。向上回退搜索其它组合。此题本身就是一个搜索的过程,找到所有的组合。 #include <iostream>#include <cmath>#in

OJ-0905

题目 示例1: 输入:10 10 56 34 99 1 87 8 99 3 255 6 99 5 255 4 99 7 255 2 99 9 255 213 4输出:99 示例2: 输入:10 10 255 34 0 1 255 8 0 3 255 6 0 5 255 4 0 7 255 2 0 9 255 213 5输出:255 import java.util.

EasyConnect 现实 Harfbuzz version too old 解决方案

https://www.cnblogs.com/cocode/p/12890684.html

每日OJ_牛客_Emacs计算器(逆波兰表达式)

目录 牛客_Emacs计算器(逆波兰表达式) 解析代码 牛客_Emacs计算器(逆波兰表达式) Emacs计算器__牛客网 解析代码 逆波兰表达式(后缀表达式)求值,需要借助栈,思路: 循环输入,获取逆波兰表达式,然后进行以下补助,直到测试完所有的测试用例: 遇到数字字符串,将该数字字符串转化为数字然后入栈。遇到操作符时,从栈顶取两个数字,然后进行该运算符所对应运算

【codeforces】gym 101137 K - Knights of the Old Republic【用最小生成树对图做集合dp】

题目链接:【codeforces】gym 101137 K - Knights of the Old Republic 考虑对图集合dp,一个连通块的dp值为两个连通块的值的和或者强制加一条新边后的最小值,取个最小值(边从小到大枚举,则强制加一条最大的边会导致连通块内较小的边一定都选,则会构成一个生成树)。用kruskal实现这个dp过程即可。 #include <bits/stdc++.h>

Android studio Plugin is too old 问题

Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to ........ 将默认的  classpath 'com.android.tools.build:gradle:2.2.0-beta2' 修改成 clas

西北工业大学oj题-兔子生崽

题目描述: 兔子生崽问题。假设一对小兔的成熟期是一个月,即一个月可长成成兔,每对成兔每个月可以生一对小兔,一对新生的小兔从第二个月起就开始生兔子,试问从一对兔子开始繁殖,一年以后可有多少对兔子? 这道题目一眼看过去就是典型的递归问题,代码如下 public class RabbitReproduction {public static void main(String[] args) {in

★ 算法OJ题 ★ 力扣209 - 长度最小的子数组

Ciallo~(∠・ω< )⌒☆ ~ 今天,简将和大家一起做一道滑动窗口算法题--长度最小的子数组~ 目录 一  题目 二  算法解析 解法⼀:暴力求解 解法二:滑动窗口 三  编写算法 一  题目 209. 长度最小的子数组 - 力扣(LeetCode) 二  算法解析 解法⼀:暴力求解 算法思路: 从前往后枚举数组中的任意⼀个元素,把它当成起始位置