uvalive4467

E - Electric Bill
Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

Description

Download as PDF

It's year 2100. Electricity has become very expensive. Recently, your electricity company raised the power rates once more. The table below shows the new rates (consumption is always a positive integer):


RangePrice
(Crazy-Watt-hour)(Americus)
$ \sim$ 1002
101 $ \sim$ 100003
10001 $ \sim$ 10000005
> 10000007
  


This means that, when calculating the amount to pay, the first 100 CWh have a price of 2 Americus each; the next 9900 CWh (between 101 and 10000) have a price of 3 Americus each and so on.

For instance, if you consume 10123 CWh you will have to pay x 100 + 3 x 9900 + 5 x 123 = 30515 Americus.

The evil mathematicians from the company have found a way to gain even more money. Instead of telling you how much energy you have consumed and how much you have to pay, they will show you two numbers related to yourself and to a random neighbor:

A:
the total amount to pay if your consumptions were billed together; and
B:
the absolute value of the difference between the amounts of your bills.

If you can't figure out how much you have to pay, you must pay another 100 Americus for such a ``service". You are very economical, and therefore you are sure you cannot possibly consume more than any of your neighbors. So, being smart, you know you can compute how much you have to pay. For example, suppose the company informed you the following two numbers: A = 1100 and B = 300. Then you and your neighbor's consumptions had to be 150 CWh and 250 CWh respectively. The total consumption is 400 CWh and then A is x 100 + 3 x 300 = 1100. You have to pay x 100 + 3 x 50 = 350 Americus, while your neighbor must pay x 100 + 3 x 150 = 650 Americus, soB is | 350 - 650| = 300.

Not willing to pay the additional fee, you decided to write a computer program to find out how much you have to pay.

Input

The input contains several test cases. Each test case is composed of a single line, containing two integers A and B, separated by a single space, representing the numbers shown to you (1$ \le$AB$ \le$109). You may assume there is always a unique solution, that is, there exists exactly one pair of consumptions that produces those numbers.

The last test case is followed by a line containing two zeros separated by a single space.

Output

For each test case in the input, your program must print a single line containing one integer, representing the amount you have to pay.

Sample Input

1100 300 
35515 27615 
0 0

Sample Output

350 
2900




#include<stdio.h>
#include<string.h>
#define INF 1<<30
int f[9]={0,0,0,200,0,29900,0,4979900};
int min(int a,int b)
{
	return a<b?a:b;
}
int chu(int k)
{
    if(k==2)
        return 0;
    if(k==3)
        return 100;
    if(k==5)
        return 10000;
    else
        return 1000000;

}
int jie(int k)
{
    if(k==2)
        return 100;
    if(k==3)
        return 10000;
    if(k==5)
        return 1000000;
    else
        return INF;

}
int du(int m)
{
    int i,j,h;
    h=0;
    if(m<=200)
    {
        h+=m/2;
        return h;
    }
    if(m<=29900)
    {
        h+=100+(m-200)/3;
        return h;
    }
    if(m<=4979900)
    {
        h+=10000+(m-29900)/5;
        return h;
    }
    else
    {
        h+=1000000+(m-4979900)/7;
        return h;
    }
    return -1;
}
int fanw(int v)
{
    if(v<=100)
        return 2;
    if(v<=10000)
        return 3;
    if(v<=1000000)
        return 5;
    else
        return 7;
}
int pay(int r)
{
    int i,j,k,l,h;
    h=0;
    k=fanw(r);
    h+=f[k]+k*(r-chu(k));
    return h;
}
int end,a,b;
void dfs(int ta,int tb,int dif)
{
    if(dif==b)
    {
        end=ta;
        return ;
    }
    if(dif>b)
    {
        return;
    }
    int ka,kb,cha,chb,tmp,i,j,k,l;
    ka=fanw(ta);
    kb=fanw(tb);
    cha=ta-chu(ka);
    chb=jie(kb)-tb;
    if(cha==0||chb==0) //到头了,tmp是0再算没意义,先退一步
    {
        dfs(ta-1,tb+1,dif+fanw(ta-1)+fanw(tb+1));
        return;
    }
    tmp=min(cha,chb);
    l=dif;
    l+=tmp*(ka+kb);   //补全之后的差值
    if(l==b)     //补完刚好相等
    {
        end=ta-tmp;
        return;
    }
    else if(l<b)  //补全也不够,退tmp
    {
        ta=ta-tmp;
        tb=tb+tmp;
        dif+=(ka+kb)*tmp;
        dfs(ta,tb,dif);
    }
    else if(l>b) //补全抄了,说明就在这个范围里出结果;
    {
        end=ta-(b-dif)/(ka+kb);
        return;
    }
}
int main()
{
    int i,j,k,l,m,n,cha,flag;
    int sum,ta,tb;
    while(scanf("%d %d",&a,&b)&&a+b)
    {
        sum=du(a);
        ta=sum/2;
        tb=sum-sum/2;
        if(ta==tb)
            cha=0;
        else
            cha=1;
        int dif=0;

        int tmp=0;
        dfs(ta,tb,0);
        printf("%d\n",pay(end));
	}


    while(0)
    {
        scanf("%d",&a);
        printf("%d\n",du(a));
    }
     return 0;
}


多源动态最优潮流的分布鲁棒优化方法(IEEE118节点)(Matlab代码实现)内容概要:本文介绍了基于Matlab实现的多源动态最优潮流的分布鲁棒优化方法,适用于IEEE118节点电力系统。该方法旨在应对电力系统中源荷不确定性带来的挑战,通过构建分布鲁棒优化模型,有效处理多源输入下的动态最优潮流问题,提升系统运行的安全性和经济性。文中详细阐述了模型的数学 formulation、求解算法及仿真验证过程,并提供了完整的Matlab代码实现,便于读者复现与应用。该研究属于电力系统优化调度领域的高水平技术复现,具有较强的工程实用价值。; 适合人群:具备电力系统基础知识和Matlab编程能力的研究生、科研人员及从事电力系统优化调度的工程技术人员,尤其适合致力于智能电网、鲁棒优化、能源调度等领域研究的专业人士。; 使用场景及目标:①用于电力系统多源环境下动态最优潮流的建模与求解;②支撑含可再生能源接入的电网调度决策;③作为鲁棒优化方法在实际电力系统中应用的教学与科研案例;④为IEEE118节点系统的仿真研究提供可复现的技术支持。; 阅读建议:建议结合提供的Matlab代码逐模块分析,重点关注不确定变量的分布鲁棒建模、目标函数构造及求解器调用方式。读者应具备一定的凸优化和电力系统分析基础,推荐配合YALMIP工具包与主流求解器(如CPLEX、Gurobi)进行调试与扩展实验。
内容概要:本文系统介绍了物联网与云计算的基本概念、发展历程、技术架构、应用场景及产业生态。文章阐述了物联网作为未来互联网的重要组成部分,通过RFID、传感器网络、M2M通信等技术实现物理世界与虚拟世界的深度融合,并展示了其在智能交通、医疗保健、能源管理、环境监测等多个领域的实际应用案例。同时,文章强调云计算作为物联网的支撑平台,能够有效应对海量数据处理、资源弹性调度和绿色节能等挑战,推动物联网规模化发展。文中还详细分析了物联网的体系结构、标准化进展(如IEEE 1888、ITU-T、ISO/IEC等)、关键技术(中间件、QoS、路由协议)以及中国运营商在M2M业务中的实践。; 适合人群:从事物联网、云计算、通信网络及相关信息技术领域的研究人员、工程师、高校师生以及政策制定者。; 使用场景及目标:①了解物联网与云计算的技术融合路径及其在各行业的落地模式;②掌握物联网体系结构、标准协议与关键技术实现;③为智慧城市、工业互联网、智能物流等应用提供技术参考与方案设计依据;④指导企业和政府在物联网战略布局中的技术选型与生态构建。; 阅读建议:本文内容详实、覆盖面广,建议结合具体应用场景深入研读,关注技术标准与产业协同发展趋势,同时结合云计算平台实践,理解其对物联网数据处理与服务能力的支撑作用。
标题基于Java的停车场管理系统设计与实现研究AI更换标题第1章引言介绍停车场管理系统研究背景、意义,分析国内外现状,阐述论文方法与创新点。1.1研究背景与意义分析传统停车场管理问题,说明基于Java系统开发的重要性。1.2国内外研究现状综述国内外停车场管理系统的发展现状及技术特点。1.3研究方法以及创新点介绍本文采用的研究方法以及系统开发中的创新点。第2章相关理论总结Java技术及停车场管理相关理论,为系统开发奠定基础。2.1Java编程语言特性阐述Java的面向对象、跨平台等特性及其在系统开发中的应用。2.2数据库管理理论介绍数据库设计原则、SQL语言及在系统中的数据存储与管理。2.3软件工程理论说明软件开发生命周期、设计模式在系统开发中的运用。第3章基于Java的停车场管理系统设计详细介绍系统的整体架构、功能模块及数据库设计方案。3.1系统架构设计阐述系统的层次结构、模块划分及模块间交互方式。3.2功能模块设计介绍车辆进出管理、车位管理、计费管理等核心功能模块设计。3.3数据库设计给出数据库表结构、字段设计及数据关系图。第4章系统实现与测试系统实现过程,包括开发环境、关键代码及测试方法。4.1开发环境与工具介绍系统开发所使用的Java开发环境、数据库管理系统等工具。4.2关键代码实现展示系统核心功能的部分关键代码及实现逻辑。4.3系统测试方法与结果阐述系统测试方法,包括单元测试、集成测试等,并展示测试结果。第5章研究结果与分析呈现系统运行效果,分析系统性能、稳定性及用户满意度。5.1系统运行效果展示通过截图或视频展示系统实际操作流程及界面效果。5.2系统性能分析从响应时间、吞吐量等指标分析系统性能。5.3用户满意度调查通过问卷调查等方式收集用户反馈,分析用户满意度。第6章结论与展望总结研究成果,提出系统改进方向及未来发展趋势。6.1研究结论概括基于Java的停车场管理
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值