A

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = ;
const int maxm = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int num[];
int main()
{
int n;
cin >> n;
for(int i=; i<=n; i++)
{
cin >> num[i];
}
int flag=;
for(int i=; i<=n; i++)
{
int time=;
int aim=num[i];
while(time--)
{
aim=num[aim];
}
if(aim==i)
{
cout<<"YES"<<endl;
return ;
}
}
cout<<"NO"<<endl;
return ;
}

B

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll Mod = ;
int main()
{
ll aim=,anser;
ll remain=1e18+;
ll n,k;
cin >> n >> k;
for(int i=;i<=k;i++)
{
ll now;
cin >> now;
if((n-1LL*n/now*now)<remain)
{
aim=i;
anser=n/now;
remain=n-1LL*n/now*now;
}
}
cout<<aim<<" "<<anser<<endl;
return ;
}

C

不能用前缀和向后推来判断 应该要向前推

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll Mod = ;
ll num[];
ll pre[];
ll ans;
ll now;
int main()
{
int n;
cin >> n;
for (int i = ; i <= n; i++)
{
scanf("%lld", num + i);
num[i + n] = num[i];
}
ll L, R;
cin >> L >> R;
for (int i = L; i < R; i++)
{
ans += num[i];
}
now = ans;
int aim = ;
for (int i = ; i <= n; i++)
{
now = now - num[ + n + R - i] + num[ + n + L - i];
if (now > ans)
{
aim = i;
ans = now;
}
}
cout << aim << endl;
return ;
}

D

转化题意为求联通块 可以并查集也可以直接DFS 答案为每个联通块内点数-1的和

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll Mod = ;
string a, b;
int gra[][];
int visit[];
int belong[];
int block[];
void dfs(int x, int aim)
{
visit[x] = ;
belong[x] = aim;
for (int i = ; i <= ; i++)
{
if (gra[x][i] && !visit[i])
{
block[aim]++;
dfs(i, aim);
}
}
}
int main()
{
for (int i = ; i <= ; i++)
{
belong[i] = ;
}
for (int i = ; i <= ; i++)
{
block[i] = visit[i] = ;
}
int n;
cin >> n;
cin >> a >> b;
for (int i = ; i < n; i++)
{
if (a[i] != b[i])
{
visit[a[i] - 'a'] = visit[b[i] - 'a'] = ;
gra[a[i] - 'a'][b[i] - 'a'] = gra[b[i] - 'a'][a[i] - 'a'] = ;
}
}
for (int i = ; i <= ; i++)
{
if (visit[i])
{
continue;
}
dfs(i, i);
}
int ans = ;
for (int i = ; i <= ; i++)
{
if (block[i] > )
{
ans += block[i] - ;
}
}
cout << ans << endl;
for (int i = ; i <= ; i++)
{
if (belong[i] != && i != belong[i])
{
cout << (char)('a' + i) << " " << (char)('a' + belong[i]) << endl;
}
}
return ;
}

E

裸的一个三分 分析题意可以得到 答案为 ans=maxn-(maxn+pre[k])/(k+1) 为凸函数

也可以记录前一个query的答案然后向后推进

因为随着最大值越来越大maxn-(maxn+pre[k])/(k+1)的值会越来越大 而你要求加进去的前缀里的数只要小于(maxn+pre[k])/(k+1)这个平均值就可以了

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll Mod = ;
ll num[];
ll pre[];
int pop;
int l, r;
double f(int x)
{
return ((double)(num[pop]) - (((double)(num[pop]) + (double)(pre[x])) / (double)(x + )));
}
double SF()
{
while (l < r - )
{
int mid = (l + r) >> ;
int mmid = (mid + r) >> ;
if (f(mid) > f(mmid))
{
r = mmid;
}
else
{
l = mid;
}
}
return max(f(l + ), max(f(l), f(r)));
}
int main()
{
int q;
int ch;
ll number;
cin >> q;
for (int i = ; i <= q; i++)
{
scanf("%d", &ch);
if (ch == )
{
scanf("%lld", &number);
num[++pop] = number;
pre[pop] = pre[pop - ] + number;
}
else
{
if (pop == )
{
cout << "0.00000000" << endl;
continue;
}
if (pop == )
{
printf("%.9f\n", (double)(num[]) - ((double)num[] + num[]) / 2.0);
continue;
}
l = , r = pop - ;
printf("%.9f\n", SF());
}
}
return ;
}

Codeforces 939 时区模拟 三分的更多相关文章

  1. Codeforces 389B(十字模拟)

    Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submi ...

  2. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  3. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  4. Codeforces 631C. Report 模拟

    C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  5. Codeforces 679B. Barnicle 模拟

    B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...

  6. CodeForces 382C【模拟】

    活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...

  7. codeforces 719C (复杂模拟-四舍五入-贪心)

    题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...

  8. CodeForces 705C Thor (模拟+STL)

    题意:给定三个操作,1,是x应用产生一个通知,2,是把所有x的通知读完,3,是把前x个通知读完,问你每次操作后未读的通知. 析:这个题数据有点大,但可以用STL中的队列和set来模拟这个过程用q来标记 ...

  9. codeforces 645C . Enduring Exodus 三分

    题目链接 我们将所有为0的位置的下标存起来. 然后我们枚举左端点i, 那么i+k就是右端点. 然后我们三分John的位置, 找到下标为i时的最小值. 复杂度 $ O(nlogn) $ #include ...

随机推荐

  1. Python 使用PyQt5进行开发(一)

    Qt  是一个1991年由Qt Company开发的跨平台C++图形用户界面应用程序开发框架.它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器. 我们先简单使用Qt进行一个小工 ...

  2. reduce、map、zip、filter使用记录

    注意:结果取完一次就没了: # -*- coding:utf-8 -*- ### functools.reduce from functools import reduce r1 = reduce(l ...

  3. [C#菜鸟]C# Hook (一)

    转过来的文章,出处已经不知道了,但只这篇步骤比较清晰,就贴出来了. 一.写在最前 本文的内容只想以最通俗的语言说明钩子的使用方法,具体到钩子的详细介绍可以参照下面的网址: http://www.mic ...

  4. 十一、RF操作滚动条

    两种方式: 方式一:window.scrollBy(0, document.body.scrollHeight) 方式二:window.scrollTo(0, document.body.scroll ...

  5. maven 配置参数详解!

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  6. python学习之requests基础

    学习地址:http://docs.python-requests.org/zh_CN/latest/user/quickstart.html#id2 使用requests发送网络请求 一.导入requ ...

  7. 【工具安装】VMware 安装教程

    介绍:介绍一下 VMware 的安装. 0x01. 下载软件 打开官网 VMware Workstation Pro 点击立即下载即可.  也可以直接使用迅雷,添加下载任务,比浏览器下载速度快些,提 ...

  8. Python编程之列表操作实例详解【创建、使用、更新、删除】

    Python编程之列表操作实例详解[创建.使用.更新.删除] 这篇文章主要介绍了Python编程之列表操作,结合实例形式分析了Python列表的创建.使用.更新.删除等实现方法与相关操作技巧,需要的朋 ...

  9. 【MM系列】SAP MM模块-分析采购收货完成标识

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-分析采购收货完成标 ...

  10. 5.使用github脚本LAZY----几个最好的发行版----自定义终端----基本命令

    使用现成的脚本 LAZY * 如果您不想手动设置,可以用这个脚本帮您设置 访问:github.com/arismelachroinos/lscript sudo apt-get git git clo ...