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的更多相关文章
随机推荐
- Vue.js项目在apache服务器部署后,刷新404的问题
原因是vue-router 使用了路由的 history 模式,这种模式充分利用 history.pushState API 来完成 URL 跳转而无须重新加载页面. const router = n ...
- 从N个元素中抽取K个不重复元素(抽奖问题)
核心就是 把N数组抽中的元素给K数组 把N数组最后一位给N数组被抽走的那一位(这时候N数组最后一位元素和被抽走的那位元素值相等) 把N数组长度减一,去除最后一位
- 用Django自动生成表遇到问题
因为以前在数据库中已经生成过Django 叫App01下的表,所以无法生成,在数据库中执行这个命令 DELETE FROM django_migrations WHERE app='App01';然后 ...
- 七牛云 融合CDN测试域名 -> 融合CDN加速域名
七牛云 融合CDN测试域名 -> 融合CDN加速域名 本篇主要讲解 如何将七牛云融合CDN测试域名 切换到自定义的加速域名上去,为什么会写这篇是因为我收到了一封 [七牛云]测试域名回收通知的邮件 ...
- window 10 安装Oracle odac 64位
下载地址:https://www.oracle.com/cn/database/technologies/windows/downloads.html 可以下载XCopy版,也可以继续往下看下载安装文 ...
- 不止开源,不止跨平台。微软的 .NET Core 还有哪些强大之处值得我们学习?
自从 2016 年微软发布了 .NET Core 1.0,至今 4 年的时间里,.NET Core 历经 7 个正式版本和几十个 Preview 版本..NET Core 作为最通用的框架,和其他软件 ...
- 我终于学会了使用python操作postgresql
一 前言 这篇文章不仅适合pgsql,更适合mysql,思路都是一致的,如果读者学会使用psycopg2操作pgsql,那么使用PyMySQL 操作mysql也是很简单:本篇文章涵盖内容广泛,提供的操 ...
- DataFrame分组和聚合
一.分组 1.语法 grouped= df.groupby(by='columns name') # grouped是一个DataFrameGroupBy对象,是可迭代的(遍历) # grouped中 ...
- [bzoj1041] [洛谷P2508] [HAOI2008] 圆上的整点
Description 求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数. Input 只有一个正整数n,n<=2000 000 000 Output 整点个数 Samp ...
- 【java面试】IO流
一.IO 1.IO概念 ·输入流:把能够读取一个字节序列的对象称为输入流(百度百科) ·输出流:把能够写一个字节序列的对象称为输出流(百度百科) 从定义上看可能会让你感到困惑,这里解释一下:]; ...