From 9c455619ee8ba84a021aa75d1e8fab3e71ec106d Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Wed, 12 Jun 2024 21:59:10 +0600 Subject: [PATCH] Add solutions for Codeforces problems 1985A, 1985B, 1985C, 1985D, and 1985E --- Codes/1985 A - Creating Words/1985A.cpp | 25 ++++++++ Codes/1985 B - Maximum Multiple Sum/1985B.cpp | 38 ++++++++++++ Codes/1985 C - Good Prefixes/1985C.cpp | 33 ++++++++++ Codes/1985 D - Manhattan Circle/1985D.cpp | 60 +++++++++++++++++++ Codes/1985 E - Secret Box/1985E.cpp | 55 +++++++++++++++++ Readme.md | 5 ++ 6 files changed, 216 insertions(+) create mode 100644 Codes/1985 A - Creating Words/1985A.cpp create mode 100644 Codes/1985 B - Maximum Multiple Sum/1985B.cpp create mode 100644 Codes/1985 C - Good Prefixes/1985C.cpp create mode 100644 Codes/1985 D - Manhattan Circle/1985D.cpp create mode 100644 Codes/1985 E - Secret Box/1985E.cpp diff --git a/Codes/1985 A - Creating Words/1985A.cpp b/Codes/1985 A - Creating Words/1985A.cpp new file mode 100644 index 0000000..edb950d --- /dev/null +++ b/Codes/1985 A - Creating Words/1985A.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +void solve() +{ + string a,b; + cin>>a>>b; + swap(a[0],b[0]); + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +void solve() +{ + int n; + cin>>n; + int mx=0,x=-1; + for(int i=2; i<=n; ++i) + { + int sum=0; + for(int j=1; j*i<=n; ++j) + { + sum+=j*i; + } + if(sum>mx) + { + mx=sum; + x=i; + } + } + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +void solve() +{ + ll n; + cin>>n; + ll mx=0, ct=0, sum=0; + for(ll i=0; i>x; + sum+=x; + mx=max(x,mx); + if(sum-mx==mx) ct++; + } + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +void solve() +{ + int n,m; + cin>>n>>m; + vectorv; + for(int i=0; i>s; + v.push_back(s); + } + int x=0,y=0, mx=0, my=0; + for(int i=0; imx) + { + mx=ct; + x=i+1; + } + } + for(int j=0; jmy) + { + my=ct; + y=j+1; + } + } + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +vector nums(ll n) +{ + vector v; + for (ll i = 2; i * i <= n; ++i) + { + while (n % i == 0) + { + v.push_back(i); + n /= i; + } + } + if (n != 1) + v.push_back(n); + return v; +} + +void solve() +{ + ll x, y, z, k; + cin >> x >> y >> z >> k; + ll mx=0; + for(ll a=1; a<=x; ++a) + { + for(ll b=1; b<=y; ++b) + { + if(k%(a*b)) continue; + ll c=k/(a*b); + if(c<=z && a*b*c==k) + { + ll ct=(x-a+1)*(y-b+1)*(z-c+1); + mx=max(ct,mx); + } + } + } + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "<