#include <iostream> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; + ; int a[maxn]; LL sum[maxn]; int main(){ std::ios::sync_with_stdio(false); int n, k; cin >> n >> k; memset(sum, , sizeof…
法一:暴力$O({n^2})$看脸过 #include<bits/stdc++.h> using namespace std; typedef long long ll; ],sum[]; int main(){ int n,k; cin>>n>>k; ;i<=n;i++){ cin>>a[i];sum[i]=sum[i-]+a[i];} bool flag=false; ;i<n;i++){ ;j<=n;j++){ if(sum[j]-s…
暴力即可!!! #include <stdio.h> #include <string.h> #include <iostream> using namespace std; typedef long long LL; const int N=1e4+10; LL a[N]; int n; int main() { int s,t; LL sum=0,k; scanf("%d%lld",&n,&k); for(int i=1;i<…
处理出前缀和,枚举k的幂,然后从前往后枚举,把前面的前缀和都塞进map,可以方便的查询对于某个右端点,有多少个左端点满足该段区间的和为待查询的值. #include<cstdio> #include<map> using namespace std; typedef long long ll; map<ll,int>cnts; int n,m,e; ll a[100010],ans; ll b[1001]; int main() { // freopen("c…
第一题: 973. K Closest Points to Origin We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is the Euclidean distance.) You may return the answer in any order. The a…