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 = 3e7 + ;
const int maxm = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 1e9 + ;
int main()
{
string a;
cin >> a;
string ans;
ans = a;
for (int i = ; i <= a.size(); i++)
{
ans += a[a.size() - i];
}
cout << ans << 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-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 3e7 + ;
const int maxm = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int ans[][];
ll mod = 1e9 + ;
int getans(int x)
{
if (x < )
{
return x;
}
else
{
int cur = ;
while (x > )
{
if (x % != )
{
cur *= x % ;
}
x /= ;
}
return getans(cur);
}
}
int main()
{
for (int i = ; i <= ; i++)
{
int now = getans(i);
for (int j = ; j <= ; j++)
{
ans[i][j] = ans[i - ][j];
}
ans[i][now]++;
}
int q;
cin >> q;
int l, r, k;
for (int i = ; i <= q; i++)
{
scanf("%d %d %d", &l, &r, &k);
cout << ans[r][k] - ans[l - ][k] << 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-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 3e7 + ;
const int maxm = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int ans[][];
ll mod = 1e9 + ;
int main()
{
int n, a, b;
cin >> n >> a >> b;
int x, y;
x = y = -;
int cnt = n / a;
for (int i = ; i <= cnt; i++)
{
if ((n - i * a) % b == )
{
x = i;
y = (n - i * a) / b;
break;
}
}
if (x == -)
{
cout << - << endl;
return ;
}
int cur = ;
for (int i = ; i <= x; i++)
{
cout << cur + a << " ";
for (int j = ; j <= a - ; j++)
{
cout << cur + j << " ";
}
cur += a;
}
for (int i = ; i <= y; i++)
{
cout << cur + b << " ";
for (int j = ; j <= b - ; j++)
{
cout << cur + j << " ";
}
cur += b;
}
//cout << endl;
return ;
}

D

https://www.cnblogs.com/AWCXV/p/8453152.html

https://www.cnblogs.com/forever97/p/cf463.html

#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
const int N = 4e5;
const int M = ;
const ll INF = 1e16;
int Q;
ll last, W[N + ], sum[N + ][M + ];
int f[N + ][M + ], cnt = ;
int main()
{
cin >> Q;
for (int i = ; i <= ; i++)
{
sum[][i] = sum[][i] = INF;
}
W[] = INF;
for(int i=;i<=Q;i++)
{
ll ope, p, q;
cin >> ope >> p >> q;
if (ope == )
{
ll R = p ^ last, w = q ^ last;
cnt++;
W[cnt] = w;
if (W[R] >= w)
{
f[cnt][] = R;
}
else
{
ll now = R;
for (int i = ; i >= ; i--)
if (W[f[now][i]] < w)
{
now = f[now][i];
}
f[cnt][] = f[now][];
}
for (int i = ; i <= ; i++)
{
f[cnt][i] = f[f[cnt][i - ]][i - ];
} sum[cnt][] = W[f[cnt][]]; for (int i = ; i <= ; i++)
{
if (f[cnt][i] == )
{
sum[cnt][i] = INF;
}
else
{
sum[cnt][i] = sum[cnt][i - ] + sum[f[cnt][i - ]][i - ];
}
}
}
else
{
ll R = p ^ last, X = q ^ last;
int len = ;
if (X < W[R])
{
cout << << endl;
last = ;
continue;
}
X -= W[R];
len++;
for (int i = ; i >= ; i--)
{
if (X >= sum[R][i])
{
X -= sum[R][i];
R = f[R][i];
len += ( << i);
}
}
cout << len << endl;
last = len;
}
}
return ;
}

Codeforces 932 数组环构造 树上LCA倍增的更多相关文章

  1. LCA(倍增在线算法) codevs 2370 小机房的树

    codevs 2370 小机房的树 时间限制: 1 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond 题目描述 Description 小机房有棵焕狗种的树,树上有N个节点, ...

  2. 【codevs2370】小机房的树 LCA 倍增

    2370 小机房的树  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond 题目描述 Description 小机房有棵焕狗种的树,树上有N个节点,节点标号为0 ...

  3. 【BZOJ5304】[HAOI2018]字串覆盖(后缀数组,主席树,倍增)

    [BZOJ5304][HAOI2018]字串覆盖(后缀数组,主席树,倍增) 题面 BZOJ 洛谷 题解 贪心的想法是从左往右,能选就选.这个显然是正确的. 题目的数据范围很好的说明了要对于询问分开进行 ...

  4. CodeVs.2370 小机房的树 ( LCA 倍增 最近公共祖先)

    CodeVs.2370 小机房的树 ( LCA 倍增 最近公共祖先) 题意分析 小机房有棵焕狗种的树,树上有N个节点,节点标号为0到N-1,有两只虫子名叫飘狗和大吉狗,分居在两个不同的节点上.有一天, ...

  5. POJ.1986 Distance Queries ( LCA 倍增 )

    POJ.1986 Distance Queries ( LCA 倍增 ) 题意分析 给出一个N个点,M条边的信息(u,v,w),表示树上u-v有一条边,边权为w,接下来有k个询问,每个询问为(a,b) ...

  6. POJ.1330 Nearest Common Ancestors (LCA 倍增)

    POJ.1330 Nearest Common Ancestors (LCA 倍增) 题意分析 给出一棵树,树上有n个点(n-1)条边,n-1个父子的边的关系a-b.接下来给出xy,求出xy的lca节 ...

  7. 牛客网 桂林电子科技大学第三届ACM程序设计竞赛 D.寻找-树上LCA(树上a到b的路径上离c最近的点)

    链接:https://ac.nowcoder.com/acm/contest/558/D来源:牛客网 寻找 小猫在研究树. 小猫在研究树上的距离. 给定一棵N个点的树,每条边边权为1. Q次询问,每次 ...

  8. LCA(最近公共祖先)——LCA倍增法

    一.前人种树 博客:最近公共祖先 LCA 倍增法 博客:浅谈倍增法求LCA 二.沙场练兵 题目:POJ 1330 Nearest Common Ancestors 代码: const int MAXN ...

  9. POJ - 1330 Nearest Common Ancestors(dfs+ST在线算法|LCA倍增法)

    1.输入树中的节点数N,输入树中的N-1条边.最后输入2个点,输出它们的最近公共祖先. 2.裸的最近公共祖先. 3. dfs+ST在线算法: /* LCA(POJ 1330) 在线算法 DFS+ST ...

随机推荐

  1. Ping链路测试

    https://help.aliyun.com/knowledge_detail/40573.html?spm=5176.2020520165.121.d519.4b4f7029sHzfmi#TRAC ...

  2. Mybaits查询返回值是List类型的

    查询返回值是list类型的 1 首先在接口中写方法 public interface EmployeeMapper { public List<Employee> getEmpsByLas ...

  3. office toolkit怎么用(以激活office professional 2013为例)

    第一步:双击打开office toolkit工具,并选择office按钮(激活windows10选择windows按钮) 第二步:选择相应的office版本,我电脑安装的是Microsoft Offi ...

  4. Powershell + HTA

    众所周知,Powershell早已被集成到了windows的环境中,国外大牛玩得不亦乐乎,而国内圈子却很少听到讨论Powershell的,HTA更不用说了,不是学计算机的或许根本不知道这是什么鬼 Li ...

  5. 十四、RF中SSHLibrary库介绍

    A.安装SSHLibrary:   pip2 install robotframework-sshlibrary   (导入SSHLibrary) B.远程连接linux服务器 1.#连接linux服 ...

  6. ls -i

    ls的不同选项有不同的含义: -l 是用long的长格式显示 条目信息 -a 显示所有的文件, 包括隐藏文件 -i: 是显示inode, 主要是用来查看硬链接的

  7. Collector解读以及自定义

    一.Collector接口解读: Collector接口解读: public interface Collector<T, A, R> { Supplier<A> suppli ...

  8. 测开之路一百四十九:jinja2模板之宏

    jinja2是python的模板引擎, 在写python web使用的过程中,macro可以节省大量的代码 比如上一篇的渲染页面 <!DOCTYPE html><html lang= ...

  9. web端测试的测试点和注意事项

    工作中接触了不同类型的web端系统,内容不同,需求不同,测试关注点也存在些许的不同,但是总体测试思路和关注的点都类似,下面是总结自己所接触的web端系统测试的一些测试点,不尽全面,以后接触新的业务系统 ...

  10. 【DSP开发】【Linux开发】基于ARM+DSP进行应用开发

    针对当前应用的复杂性,SOC芯片更好能能满足应用和媒体的需求,集成众多接口,用ARM做为应用处理器进行多样化的应用开发和用户界面和接口,利用DSP进行算法加速,特别是媒体的编解码算法加速,既能够保持算 ...