当前位置:网站首页>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;
}
边栏推荐
- 腾讯游戏客户端开发面试 (Unity + Cocos) 双重轰炸 社招6轮面试
- Deep learning website
- Mat file usage
- The persistence mode of redis - RDB and AOF persistence mechanisms
- 第七章 行为级建模
- 由排行榜实时更新想到的数状数值
- 2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills
- 2022 new examination questions for crane driver (limited to bridge crane) and question bank for crane driver (limited to bridge crane) operation examination
- 5. Contrôle discret et contrôle continu
- 滑环使用如何固定
猜你喜欢

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!!!

Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings

2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills

Gnuradio transmits video and displays it in real time using VLC

Scalar / vector / matrix derivation method

图解网络:揭开TCP四次挥手背后的原理,结合男女朋友分手的例子,通俗易懂

The persistence mode of redis - RDB and AOF persistence mechanisms

ANSI / nema- mw- 1000-2020 magnetic iron wire standard Latest original

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

Probability distribution
随机推荐
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
Understanding of expectation, variance, covariance and correlation coefficient
Call (import) in Jupiter notebook ipynb . Py file
2022 R1 fast opening pressure vessel operation test question bank and R1 fast opening pressure vessel operation free test questions
Optimization of ecological | Lake Warehouse Integration: gbase 8A MPP + xeos
regular expression
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds
能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
Anaconda3 tutorial on installing and adding Tsinghua image files
Mysql database (2)
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
The persistence mode of redis - RDB and AOF persistence mechanisms
qt-使用自带的应用框架建立--hello world--使用min GW 32bit
Transportation, new infrastructure and smart highway
用户之声 | 冬去春来,静待花开 ——浅谈GBase 8a学习感悟
How does Matplotlib and PIL image integrate and save multiple pictures into one picture
qt--將程序打包--不要安裝qt-可以直接運行
Qt - - Packaging Programs - - Don't install Qt - can run directly
Introduction to natural language processing (NLP) based on transformers
Grey correlation analysis link (portal) matlab