当前位置:网站首页>Codeforces Round #649 (Div. 2)——A. XXXXX
Codeforces Round #649 (Div. 2)——A. XXXXX
2022-07-08 01:41:00 【Not long】
Topic link :https://codeforces.com/problemset/problem/1364/A
Title Description : When only the beginning and end of the data string can be deleted , Find the longest , Can not be x The length of the substring divisible .
Their thinking : greedy ( During the input process , When sum cannot be x Divisible time , Take the length of the substring for comparison and update ( l = max( l,max( i,n - i )))i Is the first length on the left ( Similarly, the number on the right is deleted ),n-i Is the length of the right tail ( Similarly, the number on the left is deleted ).
Code :
#include<iostream>
#include<algorithm>
using namespace std;
int num[100005];
int main()
{
int t;
cin >> t;
while (t--)
{
int n, x;
cin >> n >> x;
int l = -1, sum = 0;
for (int i = 1; i <= n; i++)
{
cin >> num[i];
sum += num[i];
if (sum % x)
l = max(l, max(i, n - i));
}
cout << l << endl;
}
return 0;
}
边栏推荐
- 滑环使用如何固定
- From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
- Break algorithm --- map
- 如何让导电滑环信号更好
- 2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
- 2021-03-06 - play with the application of reflection in the framework
- 2021 tea master (primary) examination materials and tea master (primary) simulation test questions
- 2022 high altitude installation, maintenance and demolition examination materials and high altitude installation, maintenance and demolition operation certificate examination
- Redis集群
- Write a pure handwritten QT Hello World
猜你喜欢

The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1

Kindle operation: transfer downloaded books and change book cover

第七章 行为级建模

qt--将程序打包--不要安装qt-可以直接运行

为什么更新了 DNS 记录不生效?

Understanding of maximum likelihood estimation

2022 R1 fast opening pressure vessel operation test question bank and R1 fast opening pressure vessel operation free test questions

5. Discrete control and continuous control

About snake equation (5)

不算不知道,花呗分期的真实利率居然这么高
随机推荐
Matlab method is good~
break net
ANSI / NEMA- MW- 1000-2020 磁铁线标准。. 最新原版
Problems of font legend and time scale display of MATLAB drawing coordinate axis
3、多智能体强化学习
STM32GPIO口的工作原理
碳刷滑环在发电机中的作用
php 获取音频时长等信息
PHP to get information such as audio duration
Kindle operation: transfer downloaded books and change book cover
How does Matplotlib and PIL image integrate and save multiple pictures into one picture
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
如果时间是条河
2021-03-06 - play with the application of reflection in the framework
Chapter 7 behavior level modeling
LeetCode 练习——剑指 Offer 36. 二叉搜索树与双向链表
Application of state mode in JSF source code
LaTeX 中 xcolor 颜色的用法
Understanding of prior probability, posterior probability and Bayesian formula
生态 | 湖仓一体的优选:GBase 8a MPP + XEOS