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. @清晰掉 GNU C __attribute__

    __attribute__((packed))详解 1. __attribute__ ((packed)) 的作用就是告诉编译器取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐,是GCC特有 ...

  2. Python 使用Qt进行开发(三)

    下面我们实现日期时间框的添加,表示日期时间的文本框可以使用QtWidgets控件下的 QDateEdit() , QTimeEdit() , QDateTime() 三个方法实现. 1,使用QDate ...

  3. leetcode 125 验证回文字符串 Valid Palindrome

    验证回文字符串 C++ 思路就是先重新定义一个string ,先遍历第一遍,字符串统一小写,去除空格:然后遍历第二遍,首尾一一对应比较:时间复杂度O(n+n/2),空间O(n); class Solu ...

  4. python3 导入模块

    python3导入模块和python2  有些不同   需要指定相对目录 如,在Project下有一个nlp目录里面有一个ltp模块,则 from n1.ltp import Clawer

  5. 测开之路一百五十三:ajax之load、get、ajax在项目中的体现

    在查询的时候是使用ajax进行请求的 目录结构 personal.models from datetime import datetimefrom flask_sqlalchemy import SQ ...

  6. CSS样式div

    页面中,有很多样式标签:div标签,对标签定位的地方有: 1.<head>标签里加<style>标签,在<style>标签中添加样式.如: <style> ...

  7. linux打包

    1.打成tar包 sudo tar -zcf boot.tar /boot/ 2.打成zip包 sudo zip -r boot.zip ./*

  8. Intellij Idea使用教程汇总篇

    Java编程强大的工具IDEA使用教程及一些快捷键收藏如下: https://blog.csdn.net/fanrenxiang/article/details/80503490

  9. 数据结构系列之2-3-4树的插入、查找、删除和遍历完整版源代码实现与分析(dart语言实现)

    本文属于原创,转载请注明来源. 在上一篇博文中,详细介绍了2-3树的操作(具体地址:https://www.cnblogs.com/outerspace/p/10861488.html),那么对于更多 ...

  10. Go语言入门篇-基本流程控制

    一.if语句 二.switch语句 三.for语句 四.select语句