当前位置:网站首页>E - Lucky Numbers
E - Lucky Numbers
2022-06-13 04:39:00 【I would like to have egg yolk and meat dumplings】
Portal :
The question : Here's a long one for you n-1 Sequence s, There is also a long m Of x Sequence , They are called lucky numbers .
Define a length of n Sequence a If the following conditions are met, then this is a good sequence :
a[i]+a[i+1]=s[i]
Construct a good sequence so that the most numbers in the sequence are lucky numbers .
analysis :m<=10, Consider enumeration , Put each a[i]=x[j]. It is easy to find and determine a A value of the sequence can be determined a Sequence , That is to say a The eigenvalue of the sequence is a[1]. Suppose the sequence of the optimal solution is a[1],a[2],s[3]..., So if and only if a[i]=a[i] This sequence appears once , thus , You can turn the problem into Find the number of the most frequent sequences . use map And eigenvalues .
Code :
#include<bits/stdc++.h>
using namespace std;
#define int long long
int sum[100005];
int ss[100005];
int x[15];
map<int,int>mp;
signed main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n-1;i++)
{
cin>>sum[i];
}
for(int i=2;i<=n;i++)
{
ss[i]=sum[i-1]-ss[i-1];
}
for(int i=1;i<=m;i++)
{
cin>>x[i];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
int now=x[j];
int tmp;
if(i%2) tmp=now-ss[i];
else tmp=ss[i]-now;
mp[tmp]++;
}
}
int maxx=0;
for(auto it:mp)
{
maxx=max(maxx,it.second);
}
cout<<maxx<<endl;
}
边栏推荐
- Converting MySQL data to PostgreSQL with Navicat
- 【Flutter 問題系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 彈窗中不能二次跳轉路由問題的解决方案
- Solve the problem of running server nodemon reporting errors
- php开发16退出模块
- Online audio adjustment technology summary
- 【剑指Offer】面试题24.反转链表
- Collection of some compatibility issues
- Time format method on the official demo of uniapp
- E - Lucky Numbers
- Use go to add massive data to MySQL
猜你喜欢
【JS解决】leedcode 117. 填充每个节点的下一个右侧节点指针 II
Small program imitating Taobao Jiugong grid sliding effect
Express framework knowledge - Art template template, cookie, session
[try to hack] upload labs (temporarily write to 12)
Li Kou brush question 338 Bit count
Colab使用教程(超级详细版)及Colab Pro/Pro+评测
Redis
Converting MySQL data to PostgreSQL with Navicat
Catalan number
Internet people a few years ago vs Internet people today
随机推荐
Vercel 使用 HTTP 缓存
Clear timer failure
2022 chlorination process operation certificate examination question bank and simulation examination
PHP development 16 exit module
Express scaffold creation
Blockly learning ----2 Code generation, grid, scaling, events, storage
The data obtained from mongodb query data command is null
Time format method on the official demo of uniapp
SQL advanced challenge (1 - 5)
Analyse du principe de mise en œuvre d'un éditeur de texte open source markdown - to - rich
Latex operation
Go/golang connection to database
Tita: Xinrui group uses one-to-one talk to promote the success of performance change
力扣刷题338.比特位计数
Sword finger offer 56 - I. number of occurrences in the array
Go scheduled task cron package usage
promise处理js多线程全部获得结果后同一处理结果
Ctfshow SQL injection (231-253)
Applet - uniapp realizes the functions of two-dimensional code picture pop-up and picture saving
Notes on uni app