最水的一场CF..

A. Vanya and Cubes
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes, and so on. Thus, the i-th level of the pyramid must have 1 + 2 + ... + (i - 1) + i cubes.

Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.

Input

The first line contains integer n (1 ≤ n ≤ 104) — the number of cubes given to Vanya.

Output

Print the maximum possible height of the pyramid in the single line.

Sample test(s)
input
1

output
1

input
25

output
4

没什么好说的,直接乱搞

/********************
1+2+...+x <= n, 得到最大的x
CF 492A Vanya and Cubes
**********************/#include<bits/stdc++.h>
using namespace std;int main(){int n, i, ans = 0, sum = 0, temp = 0;cin>>n;for(i = 1; i <= n; i ++){temp += i;sum += temp;if(sum > n)break;ans ++;}cout<<ans<<endl;
}

View Code

B. Vanya and Lanterns
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point l. Then the i-th lantern is at the point ai. The lantern lights all points of the street that are at the distance of at most d from it, where d is some positive number, common for all lanterns.

Vanya wonders: what is the minimum light radius d should the lanterns have to light the whole street?

Input

The first line contains two integers nl (1 ≤ n ≤ 1000, 1 ≤ l ≤ 109) — the number of lanterns and the length of the street respectively.

The next line contains n integers ai (0 ≤ ai ≤ l). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of the street.

Output

Print the minimum light radius d, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.

Sample test(s)
input
7 1515 5 3 7 9 14 0

output
2.5000000000

input
2 52 5

output
2.0000000000

注意边界处理

/********************
1 ≤ l ≤ 10^9的路上,给出一堆一维的点 1000个之内,为路灯。所有路灯的照明范围相同,问能照明整条路的最小范围是多少
相邻两个点距离最大值/2,0-第一个路灯 最后一个路灯-l
取最大值
第一反应居然还二分了一下真是被自己蠢死= =
CF 492A Vanya and Cubes
**********************/
#include <bits/stdc++.h>
using namespace std;
#define N 1004
int a[N];
int main(){int n, l, i, ans = 0;cin>>n>>l;for(i = 1; i <= n; i++)cin>>a[i];a[0] = 0;sort(a, a +n +1);for(i = 1; i <= n; i++){ans = max(ans, a[i] - a[i-1]);}//printf("%d\n", a[1]);ans = max(a[1] *2, ans);   ans = max((l-a[n])*2, ans);printf("%.10f\n", ans *1.0 / 2.0);
}

View Code

C. Vanya and Exams
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.

What is the minimum number of essays that Vanya needs to write to get scholarship?

Input

The first line contains three integers nravg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.

Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).

Output

In the first line print the minimum number of essays.

Sample test(s)
input
5 5 45 24 73 13 22 5

output
4

input
2 5 45 25 2

output
0

/********************
10^5门课,每门课最多得到r分,r<=10^9,需要平均分为avg,avg <= min(10^6,r)
已知第i门课已经得到ai分,1 ≤ ai ≤ r,每写bi篇论文可以多得一分,1 ≤ bi ≤ 10^6
问最少需要些多少篇论文可以获得平均分按b的值统计,即写b篇论文可以拿一分的课还能拿几分
按b 从小到大,直至凑满分数
492C. Vanya and Exams
**********************/
#include <bits/stdc++.h>
using namespace std;#define N 1000005
#define LL __int64
LL lt[N];
int n, r, avg;
long long sum = 0, nowget = 0, ans = 0;void input(){int a,  b;cin >> n >> r >> avg;sum = (LL) n * avg;memset(lt, 0, sizeof(lt));for(int i = 1; i <= n; i++){cin>>a>>b;lt[b] += (r - a);nowget += a;}
}void gao(void){sum -= nowget;for(int i = 1; i <= N; i++){if(sum > 0){ans += min(sum, lt[i]) * i;sum -= min(sum, lt[i]);}else break;}cout<<ans<<endl;
}
int main(void){input();gao();
}

View Code

D. Vanya and Computer Game
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each character spends fixed time to raise a weapon and then he hits (the time to raise the weapon is 1 / x seconds for the first character and 1 / y seconds for the second one). The i-th monster dies after he receives ai hits.

Vanya and Vova wonder who makes the last hit on each monster. If Vanya and Vova make the last hit at the same time, we assume that both of them have made the last hit.

Input

The first line contains three integers n,x,y (1 ≤ n ≤ 105, 1 ≤ x, y ≤ 106) — the number of monsters, the frequency of Vanya's and Vova's attack, correspondingly.

Next n lines contain integers ai (1 ≤ ai ≤ 109) — the number of hits needed do destroy the i-th monster.

Output

Print n lines. In the i-th line print word "Vanya", if the last hit on the i-th monster was performed by Vanya, "Vova", if Vova performed the last hit, or "Both", if both boys performed it at the same time.

Sample test(s)
input
4 3 21234

output
VanyaVovaVanyaBoth

input
2 1 112

output
BothBoth

一开始以为是要从1开始依次打这些怪物,是连续关系。。
还看成了A打一下可以掉x点,B打一下掉y点,感觉有些麻烦。
后来发现自己想多了。
打了个表,打怪以lca(x, y)为周期。周期内打个表出来。
表的大小不会超过两倍的max(x,y)
接下来取模就可以了

/********************一开始以为是要从1开始依次打这些怪物,是连续关系。。
还看成了A打一下可以掉x点,B打一下掉y点,感觉有些麻烦。
后来发现自己想多了。打了个表,打怪以lca(x, y)为周期。周期内打个表出来。
表的大小不会超过两倍的max(x,y)
接下来取模就可以了解释一下表。a每个1/x分钟打 一下可以看做每隔y分钟打一下,同样的变换b
按从小到大的打击顺序打个表
注意爆longlong re了 = =
D. Vanya and Computer Game
**********************/
#include<bits/stdc++.h>
using namespace std;
#define LL __int64
#define N 10000007
int typ[N];
string st[3] = {"Vanya","Vova", "Both"};
int main(void){int i, n,  z, j, tot =0;LL x, y;cin>>n>>x>>y;LL m = __gcd(x,y);m = x / m * y;i = j = 1;//0->xytyp[0] = 2;// cout<<m<<endl;while(i * y <= m && j * x <= m){if(i * y < j * x){typ[++tot] = 0;i++;}else if(j * x < i * y){typ[++tot] = 1;j++;}else{typ[++tot] = 2;break;}//printf("%d %d %d\n", tot, i, j);
    }
//cout<<tot<<endl;tot++;while(n--){cin>>x;cout<<st[typ[x%tot]]<<endl;}
}

View Code

E. Vanya and Field
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates(xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), then in a second he will be at cell . The following condition is satisfied for the vector: , where  is the largest integer that divides both a and b. Vanya ends his path when he reaches the square he has already visited.

Vanya wonders, from what square of the field he should start his path to see as many apple trees as possible.

Input

The first line contains integers n, m, dx, dy(1 ≤ n ≤ 106, 1 ≤ m ≤ 105, 1 ≤ dx, dy ≤ n) — the size of the field, the number of apple trees and the vector of Vanya's movement. Next m lines contain integers xi, yi (0 ≤ xi, yi ≤ n - 1) — the coordinates of apples. One cell may contain multiple apple trees.

Output

Print two space-separated numbers — the coordinates of the cell from which you should start your path. If there are several answers you are allowed to print any of them.

Sample test(s)
input
5 5 2 30 01 21 32 43 1

output
1 3

input
2 3 1 10 00 11 1

output
0 0

/********************
n*n的方格,m个点上有苹果。每次从现在的点(x, y)走到((x+dx)%n, (y+dy)%m)
n, m, dx, dy(1 ≤ n ≤ 106, 1 ≤ m ≤ 105, 1 ≤ dx, dy ≤ n)
ndx互质,ndy互质
走到之前走过的点则停止。
问任选一个点开始走最多能搞到多少苹果。一开始还想图论啥的想多了= =
注意到一堆互质,所以n是底之类的东西,也就是k*(dx) % n 当k从0~n-1可以取遍0~n-1所有值。
所以走n步之后一定回到本点,每个点都对应的可以走到(i,0),独一无二的映射。而且有(i+k*(dx))%n 显然与(0+k*(dx))%n的某种差是一个定值
因此先处理出0,0到达的点,即f[x]为到第i行的时候的列数。
这样取出最多的路径就方便了
**********************/
#include<bits/stdc++.h>
using namespace std;
#define N 1000004
int f[N], cnt[N]; void gao(void){int n, m, dx, dy;scanf("%d%d%d%d", &n, &m, &dx, &dy);int x, y, t, ans = -1, loc;x = y = 0;for(int i = 0; i < n; i++){f[x] = y;x  = (x +dx) % n;y = (y + dy) % n;}while(m--){scanf("%d%d", &x, &y);t = (y - f[x] + n) % n;cnt[t]++;if(cnt[t] > ans){ans = cnt[t];loc = t;}}printf("%d %d\n", 0, loc);
}
int main(void){gao();
}

View Code

转载于:https://www.cnblogs.com/bbbbbq/p/4170763.html

CF round280相关推荐

  1. 『参考』.net CF组件编程(4)——为自定义组件添加工具箱图标!

    前言: 在前三篇的文章中,和大家一起创建了一个用于TCP连接检测的小组件,如果你记不得了,可以通过以下链接去回顾一下: 『参考』.net CF组件编程(1)--基础之后 『参考』.net CF组件编程 ...

  2. OC对象 vs CF对象

    2019独角兽企业重金招聘Python工程师标准>>> OC对象 vs CF对象 在ARC场景下,对象所有权没有转换 使用__bridge关键字即可实现CF对象和OC对象之间的自由转 ...

  3. CF 990A. Commentary Boxes【数学/模拟】

    [链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio&g ...

  4. 推荐算法——基于协同过滤CF

    https://www.toutiao.com/a6643326861214482957/ 2019-01-06 18:21:09 前边我们已经介绍了推荐算法里的基于内容的推荐算法CB,今天我们来介绍 ...

  5. 索引贴——移动开发(.Net CF 停止更新)

    这是关于本人博客的技术索引贴,希望能方便的让您阅读到相关技术文章--不断更新中.一整理才发现,好多啊,哈哈- 一..Net CF技巧:搜集.转载一些和CF开发相关的辅助文章,比较适合初学者.开发入门者 ...

  6. 解答:CF截图保存在哪

    为什么80%的码农都做不了架构师?>>>    大家玩CF(穿越火线)的时候遇到精彩的画面总希望截图保存下来,然而有些游戏玩家截图后却不知道CF截图保存在哪!这不得不说是个悲剧,但是 ...

  7. CF里面的资源载入问题

    前一段时间已经发现CF在载入资源的时候会怪怪的,但是这一段时间都不曾记起要对这个问题研究一下.最近又发现这个问题了,实在是恼火.俗话说择日不如撞日(粤语),唉,就今天啦.这个问题是在VS2k5里面调试 ...

  8. [CF.Skills]播放嵌入资源的声音文件

    [CF.Skills]播放嵌入资源的声音文件 摘要:本文阐述了在Windows Mobile中如何播放潜入资源的声音文件KeywordsPlaySound, Windows Mobile, Embed ...

  9. CF#190DIV.1

    1 /* 2 CF#190DIV.1-C 3 题意:给你n个结点的树,给这些结点标记字母AB..Z,对于标记相同的结点路径上 4 的结点的标记必须有一个是大于该标记的:问是否可以标记(A是最大标记) ...

最新文章

  1. 「Excel技巧」Excel中根据某列的值去汇总另外一列的值
  2. java第二阶段学习day5
  3. CTF-Python常用函数语段详解;
  4. 捕捉不可控iframe的close事件_湖南大学王建锋团队:光/湿驱动的超快可逆可控致动器...
  5. 洛谷3605 Promotion Counting
  6. SPOJ1812 LCS2
  7. 1到100的二进制编码_每天经过100天的编码后,我学到了什么
  8. 开启Mysql远程登录账号
  9. 1、Java多线程基础:进程和线程之由来
  10. Linux源码安装Mysql5.7
  11. 【无标题】5 自用历程
  12. 关于解决百度网盘盘符无法删除的问题
  13. php 分页样式css样式,thinkphp5分页CSS样式代码
  14. 酷桌面:IPAD上体验office的炫“酷”移动办公应用
  15. Linux那些事儿之我是U盘(4)想到达明天,现在就要启程
  16. js修改伪元素的属性、styleSheets获取样式表,Failed to read the 'cssRules' property from 'CSSStyleSheet' Cannot acces
  17. java水果爆炸动画_5分钟快速实现Android爆炸破碎酷炫动画特效的示例
  18. 香港科大2020年TOP12人气热帖@商学院公众号
  19. 在计算机上怎么搜共享打印机,如何共享打印机,在其他电脑上怎么找到的?
  20. 从Q4财报看百度破局BAT,借智能云“化茧成蝶”仰望星辰大海

热门文章

  1. 电脑重装系统后如何在防火墙设置允许浏览器访问网络
  2. 梦寐以求滴Diablo3!!
  3. “魔兽世界”里有什么
  4. UVA 10801 Lift Hopping(最短路)
  5. 高薪行业2016年调薪预估率出炉
  6. [学习笔记] 4. 设计模式
  7. 输出、认识格式化符号
  8. 《2021网络空间测绘年报》解读|公有云资产画像与风险度量
  9. 关于隐藏文件不能显示
  10. linux 虚拟网卡与物理网卡关系,Linux Macvlan的虚拟网卡与宿主物理网卡之间的Bridge通信问题...