A

B

a,b两个序列分成K段 每一段的值相等

#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 maxn = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 3e7;
ll num[maxn];
ll num2[maxn];
//priority_queue<int, vector<int>, less<int>> que;
int main()
{
int n, m;
ll now;
cin >> n >> m;
for (int i = ; i <= n; i++)
{
scanf("%lld", num+i);
//pre[i] = pre[i - 1] + now;
}
for (int i = ; i <= m; i++)
{
scanf("%lld", num2+i);
//pre2[i] = pre2[i - 1] + now;
}
int cur = ;
int cur2 = ;
ll sum1 = num[];
ll sum2 = num2[];
int anser = ;
while (cur != n + )
{
if (sum1 == sum2)
{
anser++;
sum1+=num[++cur];
sum2+=num2[++cur2];
continue;
}
if(sum1<sum2)
{
sum1+=num[++cur];
}
else
{
sum2+=num2[++cur2];
}
}
cout<<anser<<endl;
}

C

问子序列可否全部分成0或者010 01010这种01相间的序列

用Vector和一个int指针维护 int之前的vector表示以0结尾的 之后的表示以1结尾的

如果指针在插入一个1前是在0或者全部插入完还有以1结尾的就return false

#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 maxn = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll mod = 3e7;
vector<int> ans[];
int anser = ;
int cnt = ;
//priority_queue<int, vector<int>, less<int>> que;
int main()
{
string a;
cin >> a;
int len = a.size();
for (int i = ; i < len; i++)
{
if (a[i] == '')
{
ans[++cnt].pb(i + );
}
else
{
if (cnt <= ) //!!!!!!!!!!!!
{
cout << - << endl;
return ;
}
ans[cnt--].pb(i + );
}
anser = max(anser, cnt);
}
if (cnt != anser)
{
cout << - << endl;
return ;
}
cout << anser << endl;
for (int i = ; i <= anser; i++)
{
int lenth = ans[i].size();
cout << lenth << " ";
for (int j = ; j < lenth; j++)
{
cout << ans[i][j] << " ";
}
cout << endl;
}
}

D

思维题 可以找规律做 也可以推公式做

很容易想到原本序列前N/2个数的位置是不会变的 因为这些数一旦跳了 最后序列的长度就会小于N  这些数在最后的位置下标为奇数位

然后其他跳的数 假设他跳之后的位置为P 则现在在他左边的P/2个数是原数组原来就在他左边的

右边有N-P/2个数(包括他自己)是连续的   也就是说他之前的位置往前进了N-P/2个块

所以公式就是P=P/2+N  一直循环直到P为奇数为止 这就是最终序列的数对应原来序列的位置

最后答案就是P/2+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 turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
priority_queue<int, vector<int>, less<int>> que;
ll mod = 3e7;
const int MAXN = ;
int main()
{
ll n;
ll q;
cin >> n >> q;
while(q--)
{
ll now;
cin >> now;
while(!(now%))
{
now=now/+n;
}
cout<<now/+<<endl;
}
}

Codeforces 950 010子序列拆分 数列跳棋的更多相关文章

  1. 洛谷P1415 拆分数列[序列DP 状态 打印]

    题目背景 [为了响应党中央勤节俭.反铺张的精神,题目背景描述故事部分略去^-^] 题目描述 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数.如果有多组解,则输出使得最后一个数最小的同时 ...

  2. 洛谷 P1415 拆分数列 解题报告

    拆分数列 题目背景 [为了响应党中央勤节俭.反铺张的精神,题目背景描述故事部分略去^-^] 题目描述 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数. 如果有多组解,则输出使得最后一个 ...

  3. luoguP1415 拆分数列 [dp]

    题目描述 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数.如果有多组解,则输出使得最后一个数最小的同时,字典序最大的解(即先要满足最后一个数最小:如果有多组解,则使得第一个数尽量大:如 ...

  4. Codeforces 950 D. A Leapfrog in the Array

    http://codeforces.com/contest/950/problem/D 前n/2个格子的奇数下标的数没有参与移动 候n/2个格子的奇数下标的数一定是一路移向偶数下标移 所以还原数的初始 ...

  5. Codeforces 950 C. Zebras

    http://codeforces.com/contest/950/problem/C 题意: 给出一个01序列,问能否将这个序列分为若干个0开头0结尾的序列 输出方案 如果有解,几个1能在一个序列就 ...

  6. 洛谷P1415 拆分数列(dp)

    题目链接:传送门 题目: 题目背景 [为了响应党中央勤节俭.反铺张的精神,题目背景描述故事部分略去^-^] 题目描述 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数.如果有多组解,则输 ...

  7. 洛谷P1415 拆分数列

    题目背景 [为了响应党中央勤节俭.反铺张的精神,题目背景描述故事部分略去^-^] 题目描述 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数.如果有多组解,则输出使得最后一个数最小的同时 ...

  8. jzoj4915. 【GDOI2017模拟12.9】最长不下降子序列 (数列)

    题面 题解 调了好几个小时啊--话说我考试的时候脑子里到底在想啥-- 首先,这个数列肯定是有循环节的,而且循环节的长度\(T\)不会超过\(D\) 那么就可以把数列分成三份,\(L+S+R\),其中\ ...

  9. P1415 拆分数列

    传送门 DP数列长度过大无法枚举,考虑DP设f1[i]储存以第i个字符为结尾时,的最后一个数最小时,这个数的开头的位置(很难想有木有)OK,状态有了,方程想一想就出来了:设$num[i][j]$为数列 ...

随机推荐

  1. java 强弱软虚 四种引用,以及用到的场景

    1.利用软引用和弱引用解决OOM问题:用一个HashMap来保存图片的路径和相应图片对象关联的软引用之间的映射关系,在内存不足时,JVM会自动回收这些缓存图片对象所占用的空间,从而有效地避免了OOM的 ...

  2. git连接远程仓库时,出现“ Repository not found"的解决办法

    2018-08-25 今天连接远程仓库时,出现: 原来是远程仓库地址名字错了. 解决方法: 1.找到.git目录 2.进入.git找到config文件 3.修改config里面的远程地址url

  3. legend3---Homestead常用操作代码

    legend3---Homestead常用操作代码 一.总结 一句话总结: 在虚拟机里面改变文件windows里面也会变,在windows里面改变虚拟机里面也会变,所以可以在windows里面编程或者 ...

  4. 不能访问windows installer服务

    xp系统安装msi类型的安装程序出现以下错误: 不能访问windows installer服务. 解决办法 1:运行cmd -> regsvr32 msi.dll 运行services.msc- ...

  5. leetcode-mid-others-150. Evaluate Reverse Polish Notation

    mycode   42.30%. 注意:如果不考虑符号,-1//3=-1而不是等于0,因为是向下取整 class Solution(object): def evalRPN(self, tokens) ...

  6. MVC、MVP 和 MVVM

    MVC Model–View–Controller 模型:管理应用程序的数据.逻辑和规则 视图:展示数据(可以直接从模型中获取数据) 控制器:接收输入并将其转化成模型和视图的命令 MVP Model– ...

  7. jenkins不展示set Build Description Setter插件

    问题描述: 1.jenkins 已下载 set build descripteion ,并且配置过,可以在构建历史中展示就用二维码 2.问题:构建历史中不展示二维码了,如图: 总是排查: 1.首先想到 ...

  8. Oracle 启用登录终端超时锁定功能

    远程连接oracle 会出现超时连接断开的问题,所以需要修改oracle配置. 修改超时时间10分钟 ALTER PROFILE DEFAULT LIMIT IDLE_TIME 10; 查询修改后的超 ...

  9. IDEA无法导入HttpServlet包解决方法

    1.maven项目 直接在pom.xml中添加对java servlet api的依赖即可,比较常用的一个servlet版本3.1.0的依赖如下: <!-- https://mvnreposit ...

  10. 批处理文件将多台连接的手机安装同一个APP

    :adb devices > C:\Users\aaminaxu\Desktop\a.txt :1.首先获取连接到电脑的手机的设备信息将其保存到C盘的a.txt文件中::2.将保存的txt文件中 ...