The Undefeated Magician
def is_possible(N, X):
attempts = 0
while N > 0:
N >>= 1
attempts += 1
return attempts <= X
def min_attempts(N):
left, right = 0, N
result = -1
while left <= right:
mid = (left + right) // 2
if is_possible(N, mid):
result = mid
right = mid - 1
else:
left = mid + 1
return result
T = int(input().strip())
for _ in range(T):
N = int(input().strip())
print(min_attempts(N))
def is_possible(N, X):
attempts = 0
while N > 0:
N >>= 1
attempts += 1
return attempts <= X
def min_attempts(N):
left, right = 0, N
result = -1
while left <= right:
mid = (left + right) // 2
if is_possible(N, mid):
result = mid
right = mid - 1
else:
left = mid + 1
return result
T = int(input().strip())
for _ in range(T):
N = int(input().strip())
print(min_attempts(N))
def is_satisfied(N, W, R, weights):
# Check if the weight of the rod itself is at least W
if abs(R) >= W:
return "waku waku"
# Check if Aditya Sama can balance the weights symmetrically
left_sum = 0
right_sum = 0
for weight in weights:
if weight < 0:
left_sum += abs(weight)
else:
right_sum += weight
if left_sum == right_sum and left_sum >= W:
return "waku waku"
else:
return "orewa kanashii desu"
N, W, R = map(int, input().split())
weights = list(map(int, input().split()))
print(is_satisfied(N, W, R, weights))
Aditya-Sama and Gym
# Check if the weight of the rod itself is at least W
if abs(R) >= W:
return "waku waku"
# Check if Aditya Sama can balance the weights symmetrically
left_sum = 0
right_sum = 0
for weight in weights:
if weight < 0:
left_sum += abs(weight)
else:
right_sum += weight
if left_sum == right_sum and left_sum >= W:
return "waku waku"
else:
return "orewa kanashii desu"
N, W, R = map(int, input().split())
weights = list(map(int, input().split()))
print(is_satisfied(N, W, R, weights))
Aditya-Sama and Gym
๐1
#include <iostream>
#include <vector>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
long long K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
int maxLength = -1;
long long sum = 0;
int left = 0;
for (int right = 0; right < N; ++right) {
sum += A[right];
int length = right - left + 1;
while (sum * length > K && left < right) {
sum -= A[left];
left++;
length = right - left + 1;
}
if (sum * length <= K && length > 1) {
maxLength = max(maxLength, length);
}
}
cout << maxLength << endl;
}
return 0;
}
Shiv and Subarray โ
#include <vector>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
long long K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
int maxLength = -1;
long long sum = 0;
int left = 0;
for (int right = 0; right < N; ++right) {
sum += A[right];
int length = right - left + 1;
while (sum * length > K && left < right) {
sum -= A[left];
left++;
length = right - left + 1;
}
if (sum * length <= K && length > 1) {
maxLength = max(maxLength, length);
}
}
cout << maxLength << endl;
}
return 0;
}
Shiv and Subarray โ
โค1
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
signed main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int ans=0;
while(n--){
int x;
cin>>x;
ans=(ans|x);
}
cout<<ans<<endl;
}
return 0;
}
Shiv and Subsequences โ
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
signed main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int ans=0;
while(n--){
int x;
cin>>x;
ans=(ans|x);
}
cout<<ans<<endl;
}
return 0;
}
Shiv and Subsequences โ
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
signed main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
cin>>n;
vector<int> a(n);
for(auto&x:a) cin>>x;
vector<int> suff(n,0);
suff[n-1]=n-1;
for(int i=n-2;i>=0;i--){
if(a[i]>a[suff[i+1]]) suff[i]=i;
else suff[i]=suff[i+1];
}
int ans=0;
int i=0;
while(i!=n-1){
ans+=a[suff[i+1]]*(suff[i+1]-i);
i=suff[i+1];
}
cout<<ans;
return 0;
}
Shiv and Jumpโ
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
signed main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
cin>>n;
vector<int> a(n);
for(auto&x:a) cin>>x;
vector<int> suff(n,0);
suff[n-1]=n-1;
for(int i=n-2;i>=0;i--){
if(a[i]>a[suff[i+1]]) suff[i]=i;
else suff[i]=suff[i+1];
}
int ans=0;
int i=0;
while(i!=n-1){
ans+=a[suff[i+1]]*(suff[i+1]-i);
i=suff[i+1];
}
cout<<ans;
return 0;
}
Shiv and Jumpโ
int MaxGCD(int a[], int n)
{
int Prefix[n + 2];
int Suffix[n + 2];
Prefix[1] = a[0];
for (int i = 2; i <= n; i += 1)
Prefix[i] = __gcd(Prefix[i - 1], a[i - 1]);
Suffix[n] = a[n - 1];
for (int i = n - 1; i >= 1; i -= 1)
Suffix[i] = __gcd(Suffix[i + 1], a[i - 1]);
int ans = max(Suffix[2], Prefix[n - 1]);
for (int i = 2; i < n; i += 1)
ans = max(ans, __gcd(Prefix[i - 1], Suffix[i + 1]));
return ans;
}
Shiv and gcd โ
class UserMainCode(object):
@classmethod
def solve(cls, input1, input2):
maxi = float('-inf')
total_sum = sum(input1)
for it in input1:
maxi = max(maxi, total_sum - it)
return maxi
frog in the pond โ
@classmethod
def solve(cls, input1, input2):
maxi = float('-inf')
total_sum = sum(input1)
for it in input1:
maxi = max(maxi, total_sum - it)
return maxi
frog in the pond โ
int maxLcmOfPairs(int arr[], int n){
int maxLCM = -1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
maxLCM = max(maxLCM, (arr[i] * arr[j]) / __gcd(arr[i], arr[j]));
}
}
return maxLCM;
}
Pair problem โ
int maxLCM = -1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
maxLCM = max(maxLCM, (arr[i] * arr[j]) / __gcd(arr[i], arr[j]));
}
}
return maxLCM;
}
Pair problem โ
class UserMainCode(object):
@classmethod
def reduceTheBill(cls, input1):
binary_input = bin(input1)[2:]
res = []
for i in range(len(binary_input)):
flipped_bit = '1' if binary_input[i] == '0' else '0'
flipped_binary = binary_input[:i] + flipped_bit + binary_input[i+1:]
res.append(int(flipped_binary, 2))
return min(res)
Reduce the Bill โ
@classmethod
def reduceTheBill(cls, input1):
binary_input = bin(input1)[2:]
res = []
for i in range(len(binary_input)):
flipped_bit = '1' if binary_input[i] == '0' else '0'
flipped_binary = binary_input[:i] + flipped_bit + binary_input[i+1:]
res.append(int(flipped_binary, 2))
return min(res)
Reduce the Bill โ
public static int countBountyNumbers(int N) {
int MOD = 10007;
long totalNDigitNumbers = 9 * (long) Math.pow(10, N - 1);
long noZeros = (long) Math.pow(9, N);
long oneZero = (N - 1) * 9 * (long) Math.pow(9, N - 2);
long validNumbers = (totalNDigitNumbers - noZeros - oneZero) % MOD;
if (validNumbers < 0) {
validNumbers += MOD;
}
return (int) validNumbers;
}
Bounty โ
int MOD = 10007;
long totalNDigitNumbers = 9 * (long) Math.pow(10, N - 1);
long noZeros = (long) Math.pow(9, N);
long oneZero = (N - 1) * 9 * (long) Math.pow(9, N - 2);
long validNumbers = (totalNDigitNumbers - noZeros - oneZero) % MOD;
if (validNumbers < 0) {
validNumbers += MOD;
}
return (int) validNumbers;
}
Bounty โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐BharatX is hiring for Frontend Developer
Experience: 0-2 years
Apply here:
https://apply.workable.com/bharatx/j/963F92526E/
Experience: 0-2 years
Apply here:
https://apply.workable.com/bharatx/j/963F92526E/
Workable
BharatX
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Catagrowth Technologies | 0-2 yrs | Intern and FTE opportunity | Golang / Reactjs/ NextJS/ Posture
Reach out - akshat@fealtyx.com
Intern stipend - 20k -30k with PPO opportunity
For full-time - 6-9 LPA CTC
Reach out - akshat@fealtyx.com
Intern stipend - 20k -30k with PPO opportunity
For full-time - 6-9 LPA CTC
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Amber is hiring Associate Software Engineer
For 2023, 2022 grads
Location - Pune
Check out this job at Amber: https://www.linkedin.com/jobs/view/3945238191
For 2023, 2022 grads
Location - Pune
Check out this job at Amber: https://www.linkedin.com/jobs/view/3945238191
Linkedin
Amber hiring Associate Software Engineer (React Native) in Pune, Maharashtra, India | LinkedIn
Posted 12:47:26 PM. About Amber (amberstudent.com)Long-term accommodation booking platform for students (thinkโฆSee this and similar jobs on LinkedIn.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Plivo is hiring SDET-1 (Full Time)
For 2023, 2022 grads
https://www.linkedin.com/posts/vipultiwari_plivo-2020531-software-development-engineer-activity-7205093765923921922-88Ny
For 2023, 2022 grads
https://www.linkedin.com/posts/vipultiwari_plivo-2020531-software-development-engineer-activity-7205093765923921922-88Ny
Linkedin
Vipul Tiwari on LinkedIn: Plivo - 2020531 - Software Development Engineer in Test -1 | 10 comments
Plivo is hiring !!! ๐ ๐ ๐
We're looking for talented QA to join our team as SDET-1 .
Please take a moment to review the job descriptions (JDs) and applyโฆ | 10 comments on LinkedIn
We're looking for talented QA to join our team as SDET-1 .
Please take a moment to review the job descriptions (JDs) and applyโฆ | 10 comments on LinkedIn
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐จJOB OPENING UPDATES๐จ
Company โ Frost & Sullivan
Role โ Intern - Data Science & AI Engineer
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3941301549
Company โ Cloud Elevate Technologies Pvt Ltd
Role โ Data Science Intern
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/detail/work-from-home-part-time-data-science-internship-at-cloud-elevate-technologies-pvt-ltd1717729574?utm_source=cp_link&referral=web_share
Company โ ProAnalyst
Role โ Data Analyst Interns
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3940876535
Company โ Frost & Sullivan
Role โ Intern - Data Science & AI Engineer
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3941301549
Company โ Cloud Elevate Technologies Pvt Ltd
Role โ Data Science Intern
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/detail/work-from-home-part-time-data-science-internship-at-cloud-elevate-technologies-pvt-ltd1717729574?utm_source=cp_link&referral=web_share
Company โ ProAnalyst
Role โ Data Analyst Interns
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3940876535
Linkedin
Frost & Sullivan hiring Intern - Data Science & AI Engineer in Chennai, Tamil Nadu, India | LinkedIn
Posted 7:24:19 AM. Intern - Data Science & AI Engineer - 6 Months - Paid Internship
About the Team
In Frost &โฆSee this and similar jobs on LinkedIn.
About the Team
In Frost &โฆSee this and similar jobs on LinkedIn.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Uni Cards is #hiring for Growth Analyst.
Location: Bangalore
Experience: 0-2 yrs
Job Description: https://www.iimjobs.com/j/uni-club-growth-analyst-0-2-yrs-1420423?
Location: Bangalore
Experience: 0-2 yrs
Job Description: https://www.iimjobs.com/j/uni-club-growth-analyst-0-2-yrs-1420423?
iimjobs.com
Uni Club - Growth Analyst | iimjobs.com
Job Description for Uni Club - Growth Analyst in UniCards in Bangalore for (0-2) years of experience. Apply Now!
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Onmobile Hiring for Software Engineer - 2023/24 - 10LPA - Bangalore
https://app.joinsuperset.com/students/jobprofiles/fac0cd2a-3c1e-4fa0-af1a-5583fc0391b8
https://app.joinsuperset.com/students/jobprofiles/fac0cd2a-3c1e-4fa0-af1a-5583fc0391b8
๐1
#include <iostream>
#include <vector>
using namespace std;
int andyTrucker(int N, int K, vector<int>& A) {
int maxWeight = 0;
for (int i = 0; i <= N - K; ++i) {
int currentWeight = 0;
for (int j = i; j < i + K; ++j) {
currentWeight += A[j];
}
maxWeight = max(maxWeight, currentWeight);
}
return maxWeight;
}
#include <vector>
using namespace std;
int andyTrucker(int N, int K, vector<int>& A) {
int maxWeight = 0;
for (int i = 0; i <= N - K; ++i) {
int currentWeight = 0;
for (int j = i; j < i + K; ++j) {
currentWeight += A[j];
}
maxWeight = max(maxWeight, currentWeight);
}
return maxWeight;
}