当前位置:网站首页>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;
}
边栏推荐
- qt--將程序打包--不要安裝qt-可以直接運行
- Working principle of stm32gpio port
- Transportation, new infrastructure and smart highway
- 如果时间是条河
- How does Matplotlib and PIL image integrate and save multiple pictures into one picture
- Mysql database (2)
- Talk about smart Park
- Understanding of maximum likelihood estimation
- LaTeX 中 xcolor 颜色的用法
- Problems of font legend and time scale display of MATLAB drawing coordinate axis
猜你喜欢

About snake equation (2)

COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况----几何模型的建立

Redux使用

In depth analysis of ArrayList source code, from the most basic capacity expansion principle, to the magic iterator and fast fail mechanism, you have everything you want!!!

从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值

ArrayList源码深度剖析,从最基本的扩容原理,到魔幻的迭代器和fast-fail机制,你想要的这都有!!!

Write a pure handwritten QT Hello World

Getting started STM32 -- how to learn stm32

Js中forEach map无法跳出循环问题以及forEach会不会修改原数组

2021 tea master (primary) examination materials and tea master (primary) simulation test questions
随机推荐
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况----几何模型的建立
The examination contents of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge) in 2021 and the free examination questions of the third batch of Guangdong Prov
Codeforces Round #649 (Div. 2)——A. XXXXX
批次管控如何实现?MES系统给您答案
2022 examination for safety production management personnel of hazardous chemical production units and new version of examination questions for safety production management personnel of hazardous chem
Codeforces Round #643 (Div. 2)——B. Young Explorers
用户之声 | 对于GBase 8a数据库学习的感悟
Redis cluster
The persistence mode of redis - RDB and AOF persistence mechanisms
生态 | 湖仓一体的优选:GBase 8a MPP + XEOS
快速熟知XML解析
3. Multi agent reinforcement learning
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
Redis集群
break net
Version 2.0 de tapdata, Open Source Live Data Platform est maintenant disponible
After modifying the background of jupyter notebook and adding jupyterthemes, enter 'JT -l' and the error 'JT' is not an internal or external command, nor a runnable program
2、TD+Learning
Call (import) in Jupiter notebook ipynb . Py file
php 获取音频时长等信息