

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <bits/stdc++.h>
#define Task "bai1"
#define ll long long
#define maxn 100005
using namespace std;
int a,b,k,x;
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);cout.tie(NULL);
if(fopen(Task".inp", "r"))
{
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
cin >> a >> b >> k;
for (int i=1;i<=k;i++)
{
if (i%2==1) x=x+a;
else x=x-b;
}
cout << x;
}
---
note:
#include <bits/stdc++.h>
#define Task "CHANLE"
#define ll long long
using namespace std;
const int N = 2*1e5+5,M=1e6+5;
ll n,m,t,ans;
ll a[N],chan[M],le[M];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);cout.tie(nullptr);
if (fopen(Task".inp","r"))
{
freopen(Task".inp","r",stdin);
freopen(Task".out","w",stdout);
}
cin >> n >> m;
for (int i=1;i<=n;i++)
{
cin >> a[i];
if (a[i]%2==0) chan[i]=a[i];
else le[i]=a[i];
}
for (int i=1;i<=n;i++)
{
chan[i]=chan[i-1]+chan[i];
le[i]=le[i-1]+le[i];
}
// for (int i=1;i<=n;i++) cout << chan[i] << ' ';
// cout << '\n';
// for (int i=1;i<=n;i++) cout << le[i] << ' ';
// cout << '\n';
for (int i=1;i<n;i++)
{
for (int j=i+1;j<=n;j++)
if ((chan[j]-chan[i-1])>0&&(le[j]-le[i-1])>0)
{
t=(chan[j]-chan[i-1])-(le[j]-le[i-1]);
if (t<=m&&t>=0) ans++;
//cout << i << ' ' << j << ' ' << t << '\n';
}
}
cout << ans;
return 0;
}
//docs.google
//document/d/
//1m5S3xit3kK7tUCRyPiCIdDJ_GZE7VJ54feWHJ4OJolY/edit?usp=drivesdk
//1U2lclw2zKW1UTK2KfsXRGt8GOw4A7Bu3xQ-Xkjv6ubE/edit?usp=drivesdk
//1RwEOsntOoteRErFGK9pSdLHXCCYILY3qUCL7btViu8A/edit?usp=drivesdk
Hãy giúp mọi người biết câu trả lời này thế nào?

Bảng tin
0
81
0
https://hoidap247.com/cau-hoi/6217751 giúp mình đi