POJ 3369 Grocery store (枚举 打表)
来源:互联网 发布:app流程图制作软件 编辑:程序博客网 时间:2024/05/22 05:09
Description
A cashier in a grocery store seems to have difficulty in distinguishing the multiplication symbol and the addition symbol. To make things easier for him, you want to buy goods in such a way that the product of their prices is the same as the sum of their prices.
Of course, if you buy only one item, this is always true. With two items and three items, it still seems quite a boring task to you, so now you are interested in finding possible prices of four items such that the sum of the four prices is equal to the product of the four prices. You should consider the prices are in € with two digits after the decimal point. Obviously, each product costs at least one cent.
Input
This problem has no input.
Output
Print all solutions which have a sum of the four items of at most 20.00 €. For each solution, print one line with the prices of the four items in non-decreasing order, with one space character between them. You may print the solutions in any order, but make sure to print each solution only once.
Sample Input
Sample Output
0.50 1.00 2.50 16.001.25 1.60 1.75 1.841.25 1.40 1.86 2.00...
Source
Ulm Local 2007
题意:
找出4个2位数,Q,W,E,R使Q+W+E+R==Q*W*E*R且Q+W+E+R<=20。
poin:
暴力打表输出。 HDU里那题没有Special Judge所以我好像过不了,POJ里可以过。
#include <stdio.h>#include <string.h>int main(){ freopen("filename.txt", "a+", stdout); for(int a=1; a<=500; a++) { for(int b=a; b<=700; b++) { if(a+b>2000) break; for(int c=b; c<=1000; c++) { //对于每个a,b,c都有唯一确定的d,可以直接把他算出来。 int x=a+b+c; if(a*b*c<=1000000) continue; //这步是由 a+b+c+d==a*b*c*d得到,我们的值都扩大了100倍,so d=1000000*x%(a*b*c-1000000) if(1000000*x%(a*c*b-1000000)!=0) continue;//整数 int d=1000000*x/(a*c*b-1000000); if(d<c||a+b+c+d>2000) continue; double q,w,e,r; q=a/100.0; w=b/100.0; e=c/100.0; r=d/100.0; printf("%.2lf %.2lf %.2lf %.2lf\\n",q,w,e,r); } } }}
- POJ 3369 Grocery store (枚举 打表)
- poj 3369 Grocery store 枚举
- POJ 3369 Grocery store 可能会
- Grocery Store OpenCart 自适应主题模板 ABC-0327
- poj 3292 (打表)
- hdu 4715 Difference Between Primes (打表 枚举)
- ZOJ3861 Valid Pattern Lock(DFS||打表+枚举)
- USACO - 2.2 Preface Numbering(打表枚举)
- HDU 1406 完数(枚举+打表)
- UVa 1583 Digit Generator(枚举+打表)
- POJ-2591(经典打表)
- POJ 3746 Teacher YYF (打表)
- POJ 2083 Fractal (打表乱搞)
- poj Sumsets 2229 (机智打表)
- poj 3126(素数打表)
- poj 3126 (BFS + 素数打表)
- poj 2262 打表
- poj 1338 打表
- JVM内存区域
- pip批量更新过期库
- Android-新闻客户端
- Java IO流总结
- 什么是集中管控式大数据安全架构?
- POJ 3369 Grocery store (枚举 打表)
- 书和软件----自备
- Effective Java读书笔记二十(Java Tips.Day.20)
- 使用js在table中添加一行
- sony手机
- spark读取hdfs文件的路径使用正则表达式
- const int *, int const*, int* const
- mysql官方文档Clustered and Secondary Indexes翻译
- 【Codeforces 796 B. Find The Bone】