首页 > 试题广场 >

Old Bill

[编程题]Old Bill
  • 热度指数:28879 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    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.
示例1

输入

72
6 7 9
5
2 3 7
78
0 0 5

输出

3 2 511
9 5 18475
0
头像 鱼儿恋上水
发表于 2020-04-24 12:18:42
#include <iostream> #include <cstdio> using namespace std; int main(){ int n, x, y, z;//n火鸡数、xyz原价格中间三位 while(~scanf("%d", &n) 展开全文
头像 LoveJK
发表于 2022-01-09 10:58:09
#include<iostream> using namespace std; int main(){ int n,x,y,z; int price=0; //要输出的单价 while(cin>>n>>x>>y>>z){ for 展开全文
头像 渺小小螃蟹
发表于 2021-05-07 16:09:06
include<stdio.h> main(){ int n,x,y,z,a,b,c,k=0,d,e; scanf("%d\n %d %d %d",&n,&x,&y,&z); for(a=1;a<10;a++) { 展开全文
头像 牛客149943819号
发表于 2022-03-24 09:12:28
#include "stdio.h" int main(){ int x;//bill的千位 int y;//bill的百位 int z;//bill的十位 int n;//鸡的个数 int pay; while(scanf("%d %d %d %d",&n,&x,&y,&a 展开全文
头像 ZYT涛
发表于 2022-01-08 15:51:27
思路很简单,利用两层for循环穷举出所有符合题意可能的情况,然后每出现一种情况就判断一下是否能被题目给的n整除,并保存数据,以及需要使用一个bool型的变量来判断是否存在着符合条件的数。 最后判断是否存在着符合条件的数,若无则返回0,若有则输出结果即可。 值得注意的是,这里使用的能否被整除的判断方法 展开全文
头像 复旦周杰伦
发表于 2023-02-28 19:50:55
#include <stdio.h> int main() { int N, X, Y, Z; while (scanf("%d\n%d%d%d", &N, &X, &Y, &Z) != EOF) { int $_XYZ_ = 0; int 展开全文
头像 拒绝内卷plus
发表于 2024-03-16 17:01:44
#include <stdio.h> int main() { int n; while (scanf("%d", &n) != EOF) { int x,y,z; scanf("%d %d %d&q 展开全文
头像 夜奏花
发表于 2022-06-20 20:11:24
#include <bits/stdc++.h> using namespace std; int main(){ int n,x,y,z,sum,flag=0; while(cin>>n){ cin>>x>>y>>z; fl 展开全文
头像 mrvoider
发表于 2021-03-10 10:20:13
题目大概是说 已知买火鸡的个数,和总价的十位百位千位,让我们求火鸡的单价和总价的万位个位,其实就是模拟题嘛,读懂了题意就好做了。 #include <bits/stdc++.h> using namespace std; int main() { int n = -1, x 展开全文
头像 YangWenhao
发表于 2022-05-30 16:55:49
代码如下 当然这个逻辑是OK的 #include <iostream> #include <cstdio> using namespace std; int main(){ int N,X,Y,Z; int a=1,b=0; int each = 展开全文