当前位置:网站首页>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;
}
边栏推荐
- Write a pure handwritten QT Hello World
- The solution of frame dropping problem in gnuradio OFDM operation
- common commands
- 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
- ANSI / NEMA- MW- 1000-2020 磁铁线标准。. 最新原版
- COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况----几何模型的建立
- 批次管控如何实现?MES系统给您答案
- Gnuradio3.9.4 create OOT module instances
- 5. Contrôle discret et contrôle continu
- 能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
猜你喜欢

Urban land use distribution data / urban functional zoning distribution data / urban POI points of interest / vegetation type distribution

break net

COMSOL - Construction of micro resistance beam model - final temperature distribution and deformation - establishment of geometric model

Running OFDM in gnuradio_ RX error: gr:: Log: info: packet_ headerparser_ b0 - Detected an invalid packet at item ××

Matlab code about cosine similarity

QT -- package the program -- don't install qt- you can run it directly

Talk about smart Park

From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run

3. Multi agent reinforcement learning

2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search
随机推荐
Matlab method is good~
Introduction to grpc for cloud native application development
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds
Qml 字体使用pixelSize来自适应界面
The usage of rand function in MATLAB
为什么更新了 DNS 记录不生效?
2022 R1 fast opening pressure vessel operation test question bank and R1 fast opening pressure vessel operation free test questions
qt-使用自带的应用框架建立--hello world--使用min GW 32bit
Write a pure handwritten QT Hello World
腾讯游戏客户端开发面试 (Unity + Cocos) 双重轰炸 社招6轮面试
Application of state mode in JSF source code
2021 welder (primary) examination skills and welder (primary) operation examination question bank
npm 內部拆分模塊
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small
2022 safety officer-c certificate examination paper and safety officer-c certificate simulated examination question bank
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
2021 tea master (primary) examination materials and tea master (primary) simulation test questions
2021-04-12 - new features lambda expression and function functional interface programming
PHP to get information such as audio duration
Chapter 7 behavior level modeling