Good Bye 2016
A - New Year and Hurry (water)
#include <bits/stdc++.h>
using namespace std;
int main()
{
];
; i <= ; i++)
{
a[i] = ( + i) * i / * ;
}
int n ,k;
while(~scanf("%d%d", &n, &k))
{
;
; i <= n; i++)
{
- k >= a[i]) ans = i;
}
printf("%d\n", ans);
}
;
}
B - New Year and North Pole(water)
题意:往东南西北走,最后一定要到达北极,走的方式有限制。注意坑点。
#include <bits/stdc++.h>
using namespace std;
;
int main()
{
int n;
while(~scanf("%d", &n))
{
, ok = ;
; i < n; i++)
{
];
int dis;
scanf("%d%s", &dis, dir);
] == 'S')
{
if(cur == con || dis > con || cur + dis > con)
{
ok = ;
}
cur += dis;
}
] == 'N')
{
|| dis > con || cur - dis < )
{
ok = ;
}
cur -= dis;
}
else
{
|| cur == con) ok = ;
}
}
) ok = ;
if(ok)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
;
}
C - New Year and Rating(脑洞?思维?)
题意:给你一系列比赛的分数变化值和参加的级别,问你参加完这些比赛后,你的最大rating是多少。
思路:
感觉自己想复杂了,写的又臭又长还错,其实就是维护一个最大值,一个最小值,代表参加这些比赛之前你的rating初始值的范围,然后不断更新这个范围就行了。
阿西吧,想到了维护最大最小值,但是没有用前缀和来做,你会发现每场比赛的时候无非是,rating + sum[i - 1] >= 1900,或者,rating + sum[i - 1] <= 1899两种状态,这么水的题,相岔了= =。
#include <bits/stdc++.h>
using namespace std;
+ ;
const int INF = 0x3f3f3f3f;
int sum[maxn];
int main()
{
int n;
while(~scanf("%d", &n))
{
sum[] = ;
;
; i <= n; i++)
{
int c, d;
scanf("%d%d", &c, &d);
sum[i] = sum[i - ] + c;
)
{//rating + sum[i-1] >= 1900
minn = max(minn, - sum[i - ]);
}
)
{//rating + sum[i-1] <= 1899
maxx = min(maxx, - sum[i - ]);
}
;
}
)
{
if(maxx != INF)
{
printf("%d\n", maxx + sum[n]);
}
else
{
printf("Infinity\n");
}
}
else
{
printf("Impossible\n");
}
}
;
}
D - New Year and Fireworks(分形)
题意:
思路:
我觉得这题挺好的,练练分形的思想,递归的写法,听完思路,发现自己实现无能,有点懵。然后推一个数学里头的沿直线对称,得到对应坐标点就行了。
关于(i,j)点关于直线y=f(x), y=g(x)对称的点(x',y'),初中不是学过嘛,x' = g(j),y' = f(i)。不知道这个结论的话....初中数学的知识也够推的,过(i,j)做一条垂直于y=f(x)的直线,然后求交点,然后根据交点和(i,j)得到对称点。
其实这题可以直接暴力模拟,不需要分形的去考虑。不过我还是想练练分形的写法,补一下。
#include <bits/stdc++.h>
using namespace std;
;
], n;
][maxn][maxn];
, };
, };
void map_reverse(int pax, int pay, int dir, int cur)
{
; i < maxn; i++)
{
; j < maxn; j++)
{
][i][j])
{
ma[cur][i][j] = true;
)
ma[cur][j + (pax - pay)][i - (pax - pay)] = true;
)
ma[cur][ * pax - i][j] = true;
}
}
}
}
void f(int pax, int pay, int dir, int cur)
{
if(cur != n)
{
f(pax + dx[dir] * (t[cur] - ) + dx[dir ^ ], pay + dy[dir] * (t[cur] - ) + dy[dir ^ ], dir ^ , cur + );
map_reverse(pax, pay, dir, cur);
}
; i < t[cur]; i++)
{
ma[cur][pax + dx[dir] * i][pay + dy[dir] * i] = true;
}
}
int main()
{
scanf("%d", &n);
; i <= n; i++)
{
scanf("%d", &t[i]);
}
f(maxn / , maxn / , , );
;
; i < maxn; i++)
{
; j < maxn; j++)
{
][i][j])
cnt++;
}
}
printf("%d\n", cnt);
;
}
Good Bye 2016的更多相关文章
- codeforces Good bye 2016 E 线段树维护dp区间合并
codeforces Good bye 2016 E 线段树维护dp区间合并 题目大意:给你一个字符串,范围为‘0’~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问 ...
- Good Bye 2016 A. New Year and Hurry【贪心/做题目每道题花费时间按步长为5等差增长,求剩余时间够做几道题】
A. New Year and Hurry time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Good Bye 2016 E. New Year and Old Subsequence
传送门 题意: 给出一个长度为\(n\)的串,现在有\(q\)个询问,每个询问是一个区间\([l,r]\),要回答在区间\([l,r]\)中,最少需要删多少个数,满足区间中包含\(2017\)的子序列 ...
- Good Bye 2016 - D
题目链接:http://codeforces.com/contest/750/problem/D 题意:新年烟花爆炸后会往两端45°差分裂.分裂完后变成2部分,之后这2部分继续按这种规则分裂.现在给你 ...
- Good Bye 2016 - C
题目链接:http://codeforces.com/contest/750/problem/C 题意:在CF中,每个人都有个Rank值. 当Rank>=1900时,为DIV1.Rank< ...
- Good Bye 2016 - B
题目链接:http://codeforces.com/contest/750/problem/B 题意:地球的子午线长度为40000,两极点的距离为20000.现在你从北极出发,按照题目输入方式来走. ...
- Good Bye 2016 - A
题目链接:http://codeforces.com/contest/750/problem/A 题意:有n场比赛要打,第i场比赛需要花i*5分钟来完成,比赛从20:00开始.然后新年派对24:00开 ...
- Good Bye 2016 //智商再次下线,边界爆炸.....
A B很水就略了.. C.又是一次wannafly一样的判断区间的..... 边界设为2000000 正好GG...... fst的时候立马想到上次也是这么wa过的...... 所以下次遇到这种题 ...
- Codeforces Good Bye 2016 D 模拟搜索?
给出烟花的爆炸方式和爆炸次数 问最后有多少个格子会被炸到 如果dfs的话会超时... 利用模拟每一层来搜索..? 思想就是一开始有一个爆炸点向上 然后模拟完第一段 会产生一个爆炸点 朝两个方向 就用v ...
随机推荐
- 【IOS】将一组包含中文的数据按照#ABC...Z✿分组
上一篇文章[IOS]模仿windowsphone列表索引控件YFMetroListBox里面 我们一步步的实现了WindowsPhone风格的索引. 但是有没有发现,如果你要实现按照字母排序,你还得自 ...
- lcov和gcov的使用错误
编译使用的gcc版本和gcov的版本对不上的话,使用lcov和gcov的时候会报错 lcov的错误: [xx@localhost XXX]$ lcov --capture --directory co ...
- [IOS]JSPatch
用途 修复线上出现的紧急crash,热更新 例子 demo 原理解读 在程序didFinishLaunch时候执行,[JPEngine startEngine], startEngine做了对解析js ...
- shell test用法
1)判断表达式 if test (表达式为真) if test !表达式为假 test 表达式1 –a 表达式2 两个表达式都为真 test 表达式1 –o 表达式 ...
- 疑问,关于win64无法使用debug的问题
学习汇编语言的过程中,无法使用debug.exe,怎么办? 使用这篇文章中的解决方案 http://www.cnblogs.com/xuepeng0521/p/3661598.html 结果调试程序的 ...
- Ubuntu 手动更新firefox的flash插件
Ubuntu下 Firefox更新flash插件老是提示失败,自己动手丰衣足食啊. 1.下载tar文件,地址:http://get.adobe.com/cn/flashplayer/?no_redir ...
- C和指针 第十八章 性能评测工具gprof
linux平台下的gprof评测工具可以对程序进行分析,需要在编译时加上-pg选项,如上一章的二叉树代码: gcc -pg main.c ArrayBinaryTree.h ArrayBinaryTr ...
- Html to Pdf 的另类解决方案
Background 项目里要求将一个HTML页面(支付结果)生成pdf文档.页面有图片,有表格,貌似开源的iTextSharp应付不了. 在一番搜索之后,找到了wkhtmltopdf,一个命令行的开 ...
- angularjs $scope.$apply 方法详解
myApp.controller('firstController',function($scope,$interval){ $scope.date = new Date(); setInterval ...
- [BZOJ1251]序列终结者
[BZOJ1251]序列终结者 试题描述 网上有许多题,就是给定一个序列,要你支持几种操作:A.B.C.D.一看另一道题,又是一个序列 要支持几种操作:D.C.B.A.尤其是我们这里的某人,出模拟试题 ...