1583: [Usaco2009 Mar]Moon Mooing 哞哞叫

Time Limit: 10 Sec  Memory Limit: 64 MB
Submit: 244  Solved: 126
[Submit][Status][Discuss]

Description

Input

第一行两个数,C和N

第二行3个数,a1,b1,c1 第三行3个数,a2,b2,c2

Output

一个整数代表最长的那一次嚎叫

Sample Input

3 10
4 3 3
17 8 2

Sample Output

65

HINT

 

Source

Gold

题解:难以想象USACO竟然有此般水题,更何况还是GOLD DIVISION。。。(PS:但是我会告诉你我不仅仅第一反应是用堆做,而且还逗比了一次——忘开int64了TT)

其实,由于题目中说了\( d_1 \leq a_1 \)和\( d_2 \leq a_2 \),所以满足\( \frac{a_1}{d_1} \geq 1 \)和\( \frac{a_2}{d_2} \geq 1 \),所以整个迭代式处于一个上升的阶段,也就是说问题就完全成了一个类似归并排序的东西了——直接两条线线性合并下搞定,时间复杂度\( O\left( N \right) \)

 /**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ var
i,j,k,l,m,n,a1,b1,c1,a2,b2,c2,i1,i2:longint;
x1,x2:int64;
a:array[..] of int64;
begin
readln(m,n);
readln(a1,b1,c1);
readln(a2,b2,c2);
a[]:=m;i:=;
i1:=;i2:=;
x1:=(a1*m) div c1+b1;
x2:=(a2*m) div c2+b2;
while i<=n do
begin
if x1<x2 then
begin
if x1<>a[i-] then
begin
a[i]:=x1;
inc(i);
end;
inc(i1);
x1:=(a[i1]*a1) div c1+b1;
end
else
begin
if x2<>a[i-] then
begin
a[i]:=x2;
inc(i);
end;
inc(i2);
x2:=(a[i2]*a2) div c2+b2;
end;
end;
writeln(a[n]);
readln;
end.

1583: [Usaco2009 Mar]Moon Mooing 哞哞叫的更多相关文章

  1. [BZOJ1583] [Usaco2009 Mar]Moon Mooing 哞哞叫(队列)

    传送门 思想有点像蚯蚓那个题 #include <cstdio> #define N 4000001 #define LL long long #define min(x, y) ((x) ...

  2. BZOJ1583: [Usaco2009 Mar]Moon Mooing 哞哞叫

    给n<=4000000,c,a1,b1,c1,a2,b2,c2,以c为初始得到的数,每次可以把得到的某个数x进行操作f1(x)=a1*x/c1+b1,f2(x)=a2*x/c2+b2,求最后能得 ...

  3. [USACO09MAR]Moon哞哞叫Moon Mooing(模拟)

    链接:https://ac.nowcoder.com/acm/contest/1086/F来源:牛客网 题目描述 A full moon casts some sort of spell on the ...

  4. bzoj 3399: [Usaco2009 Mar]Sand Castle城堡

    3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec  Memory Limit: 128 MB Description 约翰用沙子建了一座城堡.正 ...

  5. BZOJ3401: [Usaco2009 Mar]Look Up 仰望

    3401: [Usaco2009 Mar]Look Up 仰望 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 87  Solved: 58[Submit ...

  6. BZOJ3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队

    3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 89  Solve ...

  7. BZOJ3399: [Usaco2009 Mar]Sand Castle城堡

    3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 22  Solved: 17[Sub ...

  8. BZOJ 3401: [Usaco2009 Mar]Look Up 仰望( 单调栈 )

    n <= 105 , 其实是10 ^ 5 ....坑...我一开始写了个模拟结果就 RE 了.. 发现这个后写了个单调栈就 A 了... ---------------------------- ...

  9. 3399: [Usaco2009 Mar]Sand Castle城堡

    3399: [Usaco2009 Mar]Sand Castle城堡 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 37  Solved: 32[Sub ...

随机推荐

  1. 10款面向HTML5 画布(Canvas)的JavaScript库

    https://www-evget-com/article/2014/4/9/20799.html

  2. SoapUI:使用Excel进行参数化

    本章中学习如下内容: 1)         使用DataSource调用Excel中的数据给接口参数化: 2)         使用DataSource Loop使得测试用例根据Excel中的取值循环 ...

  3. 基于Ubuntu 14.04构建tomcat7镜像

    1.创建Dockerfile文件(如果在Windows下编辑文件,一定要将格式转化为Linux格式文件,否则将导致Linux下查看文件每行多一个^M) # Pull base image FROM u ...

  4. 对lua中_ENV表的理解(lua5.2版本以后)

    当我拿到_ENV表的时候,会去想这个_ENV表是干什么用的? 首先看如下代码: print(_ENV) --0x1d005f0 print(_G) --0x1d005f0 ViewCode 看了上面的 ...

  5. 微信小程序之快速接入七牛云

    小程序为什么要接入云? 目前,开发者在开发小程序过程中,主要遇到以下几个问题: 小程序发布大小超限 微信官方限制小程序的发布代码不能超过 1MB,而在实际开发过程中,一般的小程序难免会有图片等富媒体文 ...

  6. css3弹性盒子模型——回顾。

    1.box-flex属性规定框的子元素是否可伸缩其尺寸. 父元素必须要声明display:box;子元素才可以用box-flex. 语法:box-flex:value; 示例: <style&g ...

  7. 扩展jquery插件的方法

    方法1.通过一个简单的.jQuery函数prototype属性的别名(jquery.fn进行扩展) jQuery.fn.newStuff = function(){ console.log(" ...

  8. mybatis关联查询,查询结果多条,却只返回一条记录

    原因是:主表和子表的主键字段相同,可以使用别名!这是因为mybatis的内部实现机制决定的: MyBatis为了降低内存开销,采用ResultHandler逐行读取的JDBC ResultSet结果集 ...

  9. j2se 总结

    j2se在学习第二遍的时候,感觉还是比较亲切的.

  10. Code forces 719A Vitya in the Countryside

    A. Vitya in the Countryside time limit per test:1 second memory limit per test:256 megabytes input:s ...