#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll solve(ll k, ll s) {
auto comb = [](ll n) {
return n * (n - 1) / 2;
};
if (k > 3 * s) return 0;
ll ans = comb(k + 2);
if (k > s) ans -= 3 * comb(k - s + 1);
if (k - 2 >= 2 * s) ans += 3 * comb(k - 2 * s);
return ans;
}
int main() {
ll n, s;
cin >> n >> s;
cout << solve(s,n) << endl;
return 0;
}
Distribute Car Toy
Service Now ✅
Telegram:- @allcoding1_official
#define ll long long
using namespace std;
ll solve(ll k, ll s) {
auto comb = [](ll n) {
return n * (n - 1) / 2;
};
if (k > 3 * s) return 0;
ll ans = comb(k + 2);
if (k > s) ans -= 3 * comb(k - s + 1);
if (k - 2 >= 2 * s) ans += 3 * comb(k - 2 * s);
return ans;
}
int main() {
ll n, s;
cin >> n >> s;
cout << solve(s,n) << endl;
return 0;
}
Distribute Car Toy
Service Now ✅
Telegram:- @allcoding1_official
👍14
allcoding1_official
Photo
#include <iostream>Please note that the above code provides a basic framework for executing SQL queries in C++. You will need to replace
#include <sql.h>
#include <sqlext.h>
#define MAX_QUERY_LEN 1000
int main() {
// Declare variables for ODBC connection
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
// Allocate environment handle
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
// Set the ODBC version to use
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);
// Allocate connection handle
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
// Connect to the data source
retcode = SQLConnect(hdbc, (SQLCHAR*)"your_datasource", SQL_NTS, (SQLCHAR*)"username", SQL_NTS, (SQLCHAR*)"password", SQL_NTS);
// Allocate statement handle
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
// Prepare the SQL query
char query[MAX_QUERY_LEN] = "SELECT DATE_FORMAT(date_column, '%Y-%m') AS month_year, source, COUNT(*) AS total_number FROM your_table WHERE YEAR(date_column) = '2022' AND (source = 'Jobs' OR source = 'Freelancers') GROUP BY month_year, source ORDER BY month_year ASC, source ASC";
// Execute the SQL query
retcode = SQLExecDirect(hstmt, (SQLCHAR*)query, SQL_NTS);
// Fetch and process the results
while (SQLFetch(hstmt) == SQL_SUCCESS) {
// Process the retrieved data here
}
// Free the handles
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, henv);
return 0;
}
your_datasource
, username
, password
, your_table
, and date_column
with your actual database connection details, table name, and column name.Telegram:- @allcoding1_official
👍4
allcoding1_official
Photo
#define vv(a) vector<vector<int>>(a)
int solve(int n, int m, vector<vector<int>> &a)
{
vv(right)(n, vector<int>(m, 0));
vv(down)(n, vector<int>(m, 0));
vv(left)(n, vector<int>(m, 0));
for (int i = 0; i < n; i++)
{
int cnt = 0;
for (int j = m - 1; j >= 0; j--)
{
right[i][j] = cnt;
if (a[i][j] == 1)
cnt++;
}
}
for (int i = 0; i < n; i++)
{
int cnt = 0;
for (int j = 0; j < m; j++)
{
left[i][j] = cnt;
if (a[i][j] == 1)
cnt++;
}
}
for (int j = 0; j < m; j++)
{
int cnt = 0;
for (int i = n - 1; i >= 0; i--)
{
down[i][j] = cnt;
if (a[i][j] == 1)
cnt++;
}
}
int ans = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (a[i][j] == 1)
{
ans += (right[i][j] * down[i][j]);
ans += (left[i][j] * down[i][j]);
}
}
}
return ans;
}
C++
Telegram:- @allcoding1_official
int solve(int n, int m, vector<vector<int>> &a)
{
vv(right)(n, vector<int>(m, 0));
vv(down)(n, vector<int>(m, 0));
vv(left)(n, vector<int>(m, 0));
for (int i = 0; i < n; i++)
{
int cnt = 0;
for (int j = m - 1; j >= 0; j--)
{
right[i][j] = cnt;
if (a[i][j] == 1)
cnt++;
}
}
for (int i = 0; i < n; i++)
{
int cnt = 0;
for (int j = 0; j < m; j++)
{
left[i][j] = cnt;
if (a[i][j] == 1)
cnt++;
}
}
for (int j = 0; j < m; j++)
{
int cnt = 0;
for (int i = n - 1; i >= 0; i--)
{
down[i][j] = cnt;
if (a[i][j] == 1)
cnt++;
}
}
int ans = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (a[i][j] == 1)
{
ans += (right[i][j] * down[i][j]);
ans += (left[i][j] * down[i][j]);
}
}
}
return ans;
}
C++
Telegram:- @allcoding1_official
👍4❤1❤🔥1👎1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define max_v 25
bool f(double A,double B,double a,double b)
{
double d=sqrt(a*a+b*b);
double a1=asin(A/d);
double a2=asin(b/d)*2.0;
double h=cos(a1-a2)*d;
if(B>h)
return true;
else
return false;
}
int main()
{
int t;
bool flag;
cin >> t;
while(t--)
{
double A,B,a,b;
cin >> A >> B >> a >> b;
if(A<B)
swap(A,B);
if(a<b)
swap(a,b);
if(A>a&&B>b)
{
flag=true;
}
else if(A*B<=a*b||b>=B)
{
flag=false;
}else
{
flag=f(A,B,a,b);
}
if(flag)
{
cout << "Escape is possible." << endl;
}else
{
cout << "Box cannot be dropped." << endl;
}
}
return 0;
}
INFAthon 4.0
Telegram:- @allcoding1_official
using namespace std;
typedef long long LL;
#define max_v 25
bool f(double A,double B,double a,double b)
{
double d=sqrt(a*a+b*b);
double a1=asin(A/d);
double a2=asin(b/d)*2.0;
double h=cos(a1-a2)*d;
if(B>h)
return true;
else
return false;
}
int main()
{
int t;
bool flag;
cin >> t;
while(t--)
{
double A,B,a,b;
cin >> A >> B >> a >> b;
if(A<B)
swap(A,B);
if(a<b)
swap(a,b);
if(A>a&&B>b)
{
flag=true;
}
else if(A*B<=a*b||b>=B)
{
flag=false;
}else
{
flag=f(A,B,a,b);
}
if(flag)
{
cout << "Escape is possible." << endl;
}else
{
cout << "Box cannot be dropped." << endl;
}
}
return 0;
}
INFAthon 4.0
Telegram:- @allcoding1_official
👍5🔥1