当前位置:网站首页>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
- 2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
- Redis集群
- 用户之声 | 对于GBase 8a数据库学习的感悟
- Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
- ANSI / nema- mw- 1000-2020 magnetic iron wire standard Latest original
- 2022 new examination questions for crane driver (limited to bridge crane) and question bank for crane driver (limited to bridge crane) operation examination
- 滑环使用如何固定
- 碳刷滑环在发电机中的作用
- A little experience from reading "civilization, modernization, value investment and China"
猜你喜欢
Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds
快速熟知XML解析
2022 safety officer-a certificate free examination questions and safety officer-a certificate mock examination
Android 创建的sqlite3数据存放位置
Probability distribution
From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
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
About snake equation (3)
随机推荐
2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
3、多智能体强化学习
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
The usage of rand function in MATLAB
qt-使用自带的应用框架建立--hello world--使用min GW 32bit
Running OFDM in gnuradio_ RX error: gr:: Log: info: packet_ headerparser_ b0 - Detected an invalid packet at item ××
pb9.0 insert ole control 错误的修复工具
[loss function] entropy / relative entropy / cross entropy
2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills
Blue Bridge Cup embedded (F103) -1 STM32 clock operation and led operation method
NPM Internal Split module
Qt - - Packaging Programs - - Don't install Qt - can run directly
如何制作企业招聘二维码?
项目经理有必要考NPDP吗?我告诉你答案
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况---材料的添加
Matlab method is good~
Version 2.0 de tapdata, Open Source Live Data Platform est maintenant disponible
Understanding of prior probability, posterior probability and Bayesian formula
2022 high altitude installation, maintenance and demolition examination materials and high altitude installation, maintenance and demolition operation certificate examination
Write a pure handwritten QT Hello World