Codeforces_813
A.统计总时间,从总时间开始找第一个能提交的点。
#include<bits/stdc++.h>
using namespace std; int n,m,a[],ok[] = {}; int main()
{
ios::sync_with_stdio();
cin >> n;
int sum = ;
for(int i = ;i <= n;i++) cin >> a[i],sum += a[i];
cin >> m;
for(int i = ;i <= m;i++)
{
int x,y;
cin >> x >>y;
for(int j = x;j <= y;j++) ok[j] = ;
}
for(int i = sum;i <= ;i++)
{
if(ok[i])
{
cout << i << endl;
return ;
}
}
cout << - << endl;
return ;
}
B.把每个unlucky值都算出来,再算最长段。
#include<bits/stdc++.h>
using namespace std; long long x,y,l,r,a[],b[]; int main()
{
ios::sync_with_stdio();
cin >> x >> y >> l >> r;
int cnt1 = ,cnt2 = ;
a[++cnt1] = ;
b[++cnt2] = ;
while(a[cnt1] <= r/x)
{
a[cnt1+] = a[cnt1]*x;
cnt1++;
}
while(b[cnt2] <= r/y)
{
b[cnt2+] = b[cnt2]*y;
cnt2++;
}
set<long long> s;
for(int i = ;i <=cnt1;i++)
{
if(a[i] > r) continue;
for(int j = ;j <= cnt2;j++)
{
if(b[j] > r) continue;
if(a[i]+b[j] < l) continue;
if(a[i]+b[j] > r) continue;
s.insert(a[i]+b[j]);
}
}
s.insert(l-);
s.insert(r+);
long long ans = ;
for(auto it = ++s.begin();it != s.end();it++)
{
long long xx = *it;
it--;
long long yy = *it;
it++;
ans = max(ans,xx-yy-);
}
cout << ans << endl;
return ;
}
C.分两种情况,Bob一直往下跑到叶子节点或者先往上跑,再往下跑到更深的叶子节点。
#include<bits/stdc++.h>
using namespace std; int n,x,a[] = {},maxx[],ok[] = {};
int ans;
vector<int> v[]; void dfs1(int now,int pre)
{
maxx[now] = a[now];
for(int i = ;i < v[now].size();i++)
{
int t = v[now][i];
if(t == pre) continue;
a[t] = a[now]+;
dfs1(t,now);
if(ok[t]) ok[now] = ;
maxx[now] = max(maxx[now],maxx[t]);
}
} int main()
{
ios::sync_with_stdio();
cin >> n >> x;
ok[x] = ;
for(int i = ;i < n;i++)
{
int x,y;
cin >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
}
dfs1(,-);
ans = maxx[x];
for(int i = ;i <= n;i++)
{
if(ok[i])
{
if(a[x]-a[i] < a[i]) ans = max(ans,maxx[i]);
}
}
cout << ans* << endl;
return ;
}
Codeforces_813的更多相关文章
随机推荐
- Django 多表、跨表、聚合、分组查询
前期准备: 创建表 class Book(models.Model): title = models.CharField(max_length=32) price = models.DecimalFi ...
- 曹工说Spring Boot源码(8)-- Spring解析xml文件,到底从中得到了什么(util命名空间)
写在前面的话 相关背景及资源: 曹工说Spring Boot源码(1)-- Bean Definition到底是什么,附spring思维导图分享 曹工说Spring Boot源码(2)-- Bean ...
- jSignature签字板保存为图片
这是本人的第一篇博客,还不会使用.有些简陋,勿怪! 今天要讲的是使用jquery插件jSignature做一个手写板签字的功能,并将签字笔迹保存为图片. 第一步:环境准备 jquery.jSignat ...
- schedule of 2016-10-17~2016-10-23(Monday~Sunday)——1st semester of 2nd Grade
most important things to do 1.joint phd preparations 2.journal paper to write 3.solid fundamental kn ...
- Python中with标签的使用详解
1.在python DTL模板中,想要定义变量,可以通过"with"语句来实现. 2."with"语句有两种使用方式: 第一种是"with xx=xx ...
- CodeSign error: no provisioning profile at path '/Users/zhht-2015/Library/MobileDevice/Provisioning Profiles/79693141-f98b-4ac4-8bb4-476c9475f265.mobileprovision'
解决方法: 1.关闭Xcode,找到项目中的**.xcodeproj文件,点击右键,show package contents(打开包内容). 2.打开后找到project.pbxproj文件,用文本 ...
- git 控制版本
git:版本控制工具 1.进入想要进行版本控制项目的文件夹内 2.右击->Git Bash Here 3.初始化 git init 会多出一个.git隐藏文件夹 4.查看文件状体 git sta ...
- Android studio 连接真机
首先用数据线连接真机 1.打开开发者模式(小米手机mix2s为例 设置->我的设备->全部参数->连续点击MIUI版本——开启成功) 2.在更多设置中找到系统安全设置——允许安装未知 ...
- [组合数学][多项式][拉格朗日插值]count
源自 ditoly 大爷的 FJ 省队集训课件 Statement 有 \(m\) 个正整数变量,求有多少种取值方案 使得所有变量的和不超过 \(S\) 并且前 \(n\) 个变量的值都不超过 \(t ...
- 第二阶段冲刺个人任务——seven
今日任务: 整体运行测试上传到公网上的程序. 昨日成果: 搭建网络服务器,上传数据库及程序.