POJ3536Beer Refrigerator
来源:互联网 发布:苹果mac官方壁纸山峰 编辑:程序博客网 时间:2024/05/22 22:49
不想说啥了,又是if else 范围出错,要很明确的确定if 对的是不是else
否则就用if … else if 结构
我要吐血了… 用了个scanf 和 cout的混合输入输出。。。查了两个多小时啊。。。欲哭无泪啊!服了服了
附代码:
#include <iostream>using namespace std;int f[30]; //这个数组要尽量开大点int main(){ int num,count,i,j,k,a,b,c; while(scanf("%d", &num) != EOF){ count=0; for(i=1;i*i<=num;i++){ //相同的因子只存一次,当然重复存也能行的通 if(num%i==0 && i*i==num){ f[count++]=i; } else if(num%i==0){ f[count++]=i; f[count++]=num/i; } } int ans=99999999; for(i=0;i<count;i++){//第三个数就从因子里面找就是,对不~ for(j=0;j<count;j++){ if(num%(f[i]*f[j])) continue; for(k=0;k<count;k++){ if(f[i]*f[j]*f[k]!=num) continue; if(f[i]*f[j]+f[i]*f[k]+f[j]*f[k]>=ans) continue; ans = f[i]*f[j]+f[i]*f[k]+f[j]*f[k]; a=f[i];b=f[j];c=f[k]; } } } printf("%d %d %d\n", a, b, c); } return 0;}
0 0
- POJ3536Beer Refrigerator
- The Pilots Brothers' refrigerator
- 3536 Beer Refrigerator
- poj 3536 (Beer Refrigerator)
- poj 3536 Beer Refrigerator
- poj 3536 Beer Refrigerator
- The Pilots Brothers' refrigerator
- POJ2965_The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- poj2965The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- poj2965The Pilots Brothers' refrigerator
- The Pilots Brothers' refrigerator
- POJ-2965-ThePilotsBrothers'refrigerator
- The Pilots Brothers' refrigerator
- POJ2965The Pilots Brothers' refrigerator
- 通过JDBC连接hive
- iOS GCD使用指南
- Notes on Convolutional Neural Networks(阅读)
- Eclipse中禁止Console DDMS打印的方法(真的可以关闭自动弹出!)
- 文章标题
- POJ3536Beer Refrigerator
- ios utf8编码和解码
- 事务、隔离级别、锁
- 用VS.NET创建.NET可复用数据库组件
- Undefined symbols for architecture i386: "xxx", referenced from:
- lightning mdb 源代码分析(1)
- error C2275: "xxx"illegal use of this type as an expression
- mb_convert_encoding使用举例
- 分层遍历二叉树