zoj 2679 Old Bill
Old Bill
Time Limit: 2 Seconds Memory Limit: 65536 KB
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 now 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 turkey 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.
Input
The input consists of T test cases. The number of test cases (T) is given on the first line of the input file. The first line of each test case 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_.
Output
For each test case, your program has to do the following. For a test case, there may be more than one candidate for the original price or there is none. In the latter case your program is to report 0. Otherwise, if there is more than one candidate for the original price, the program is to report the two faded digits and the maximum price per turkey for the turkeys. The following shows sample input and output for three test cases.
Sample Input
3
72
6 7 9
5
2 3 7
78
0 0 5
Sample Output
3 2 511
9 5 18475
0
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int x, y, z;
int i, j;
int n, t;
scanf("%d", &t);
while(t--){
scanf("%d %d %d %d", &n, &x, &y, &z);
for(i = ; i > ; i--){
for(j = ; j >= ; j--){
int p = i * + x * + y * + z * + j;
if(p / n * n == p){
printf("%d %d %d\n", i, j, p / n);
goto RL;
}
}
}
printf("0\n");
RL: continue;
}
return ;
}
zoj 2679 Old Bill的更多相关文章
- ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题
2679:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679 2952:http://acm.zju.edu.cn/onli ...
- ZOJ 2679 Old Bill(数学)
主题链接:problemCode=2679" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProbl ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
- ZOJ Problem Set - 1001 A + B Problem
ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...
随机推荐
- 顾问Advisor Aspectj注解
顾问Advisor 通知 advice PointcutAdvisor 一个接口 是顾问的一种. . 任意单个字符 + 重复1到多次 * 重复0到多次 NameMetchMethodPointc ...
- Navicat for MySQL在ubuntu下运行没有反应
Step1: 打开Navicat官网,下载Navicat ,网址:http://www.navicat.com/en/download/download.html Step2:进入下载目录,解压压缩包 ...
- 我也质疑下petshop
很多人都研究过petshop,我开始认识分层架构也是从研究这个petshop开始的.但是我发现很多人一谈三层架构就是 petshop那一套东西.实体类,DAL,BLL那一套东西.首先我不 ...
- Web开发者应掌握的12个Firebug技巧
来源: 廖煜嵘 相信很多从事Web开发工作的开发者都听说和使用过Firebug,但可能大部分人还不知道,其实它是一个在网页设计方面功能相当强大的编辑器,它 可以对HTML.DOM.CSS.HTTP和J ...
- No input file specified的解决方法
(一)IIS Noinput file specified 方法一:改PHP.ini中的doc_root行,打开ini文件注释掉此行,然后重启IIS 方法二:请修改php.ini找到; cgi.for ...
- Linux SSH无密码login
一:ssh原理图为: 1.就是为了让两个linux机器之间使用ssh不需要用户名和密码.采用了数字签名RSA或者DSA来完成这个操作 2.模型分析 假设 A (192.168.20.59)为客户机器, ...
- 网络大牛如何回答Chrome的15个刁钻面试题?
(内容来自网络整理) Google的面试题在刁钻古怪方面相当出名,甚至已经有些被神化的味道.这里整理出15道Google面试题并一一给出了网络大牛的答案,其中不少都是流传很广的. 第1题:让你清洗西雅 ...
- 数学题 HDOJ——2086 简单归纳
哎 真的是懒得动脑子还是怎么滴... 题目如下 Problem Description 有如下方程:Ai = (Ai-1 + Ai+1)/2 - Ci (i = 1, 2, 3, .... n).若给 ...
- CPP-基础:函数指针,指针函数,指针数组
函数指针 函数指针是指向函数的指针变量. 因而“函数指针”本身首先应是指针变量,只不过该指针变量指向函数.这正如用指针变量可指向整型变量.字符型.数组一样,这里是指向函数.如前所述,C在编译时,每一个 ...
- Luogu P1782 旅行商的背包
题目传送门 卡常背包果然名不虚传 算法主体就是两种背包分开跑,先跑多重背包,再跑奇货 不知道为什么,这题二进制拆分好像要比单调队列优化快一些 然后这题毒瘤的地方就出来了: 如果一件物品的体积\(\ti ...