to:SingYes
来源:互联网 发布:pp助手mac版打不开 编辑:程序博客网 时间:2024/04/30 12:41
using System;
using System.Collections;
namespace Beep
{
public class Class3
{
static void Main(string[] args)
{
app my=new app(8000,100);
my.work();
string s=my.GetExpress();
Console.WriteLine(s);
my=new app(6000,100);
my.work();
s=my.GetExpress();
Console.WriteLine(s);
Console.ReadLine();
}
}
public class app
{
int[] intArr = new int[] {1132,544,844,929,348,1136,1066,1197};//全局变量
int boss ;
public ArrayList list = new ArrayList();//全局变量
private int mod;
private int imulti;
private int end;
private int distance;
private ArrayList alint=new ArrayList();
private Hashtable hash=new Hashtable();
public app()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public app(int iboss,int iend)
{
for(int i=0;i<intArr.Length;i++)
{
alint.Add(intArr[i]);
}
alint.Sort();
this.boss=iboss;
this.end=iend;
}
public bool work()
{
int boss=this.boss;
for(int i=this.alint.Count-1;i>=0;i--)
{
if(boss<(int)this.alint[i])
continue;
this.mod=boss%(int)this.alint[i];
this.imulti=(boss-this.mod)/(int)this.alint[i];
if(this.mod>this.end||this.mod>=0)
{
hash.Add((int)this.alint[i],this.imulti);
boss=this.mod;
}
else
{
break;
}
}
foreach(int s in hash.Keys)
{
Console.WriteLine("hash[{0}]={1}",s,hash[s]);
}
this.distance=this.GetDistance();
if(this.distance<this.end)
return true;
return false;
}
private int GetDistance()
{
int subsum=0;
foreach(int i in this.hash.Keys)
{
subsum+=(int)this.hash[i]*i;
}
return this.boss-subsum;
}
public string GetExpress()
{
string subexp="";
foreach(int i in this.hash.Keys)
{
subexp+="+"+i.ToString()+"*"+this.hash[i].ToString();
}
return this.boss.ToString()+"-("+subexp.Substring(1)+")="+this.distance.ToString();
}
}
}
- to:SingYes
- to
- 【english】to to it
- To learn, to share.
- To Read
- To Learn
- listen to
- thanks to ......
- to TTT
- TO DO ... ...
- TO ROUTLE
- To Sophia
- to:雷艾伦
- TO Z28
- to bashman
- TO 红梅
- TO EveryOne
- To gongwei8401:
- 奖励努力,而非结果
- 介绍国产的PHP MVC框架:FleaPHP
- 网页经典代码
- 线段树
- 如何在谈判中巧用理性思维
- to:SingYes
- 迁移到 Ubuntu Linux 上来用电脑
- Modern English Linguistics: A Structural and Transformational Grammar
- ASP.NET2.0的DetailsView控件配合DropDownList显示的解决办法
- 什么时候不要信任你的直觉
- 窗体之间互传数据
- 关于搜索引擎页面分析中的 javascript 处理的2个思路
- life is hard
- 没有尽头的路