Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Bhanu T.
Student at BITS pilani
Tutor Satisfaction Guarantee
Physics (Newtonian Mechanics)
TutorMe
Question:

A small block B is placed is placed on another block A of mass 7 kg and length 15 cm. Initially the block B is near the right end of block A. A constant horizontal force of 10 N is applied to the block A. All the surfaces are assumed frictionless. Find the time elapsed before the block B separates from A

Bhanu T.
Answer:

As there is no friction between A and B, when the block A moves, block B remains at rest in its position. Now, acceleration of block A = 10/7 = 1.4 ms-2 As the block starts from rest, initial velocity, u = 0 We know that s = u*t + ½ at*t 0.15 = 0 + 0.7*t*t which gives t = 0.46 s

C++ Programming
TutorMe
Question:

ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has length strictly less than 26, no such substring exists and thus it is not nice. Now, ZS the Coder tells you a word, where some of its letters are missing as he forgot them. He wants to determine if it is possible to fill in the missing letters so that the resulting word is nice. If it is possible, he needs you to find an example of such a word as well. Can you help him? Input The first and only line of the input contains a single string s (1 ≤ |s| ≤ 50 000), the word that ZS the Coder remembers. Each character of the string is the uppercase letter of English alphabet ('A'-'Z') or is a question mark ('?'), where the question marks denotes the letters that ZS the Coder can't remember. Output If there is no way to replace all the question marks with uppercase letters such that the resulting word is nice, then print  - 1 in the only line. Otherwise, print a string which denotes a possible nice word that ZS the Coder learned. This string should match the string from the input, except for the question marks replaced with uppercase English letters.

Bhanu T.
Answer:

#include <bits/stdc++.h> using namespace std; void in(){ ios_base::sync_with_stdio(0); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif } #define rep(a, b, c) for(ll (a) = (b); (a) <= (c); ++(a)) #define ALL(v) (v.begin(),v.end()) #define rev(a, b, c) for(ll (a) = (b); (a) >= (c); --(a)) #define clr(a, b) memset((a), (b), sizeof(a)) #define pb push_back #define mp make_pair #define fi first #define se second #define mod 1000000007 typedef long long i64; typedef unsigned long long ll; template <typename T> T modexp(T a,T b,T c){T ans = 1;for(T i=1;i<=b;i++){ans *= a;ans %= c;} return ans;} string s;int h[28]; bool ch(int a,int b){ int k=0; for(int i=a;i<b;i++){ h[s[i]-'?']++; // cout<<s[i]-'?'<<endl; } h[1]=1; for(int i=2;i<28;i++){ if(h[i]==0) k++; if(h[i]>1) return false; } if(h[0]==k) return true; } string change(int a,int b){int u=a-1; char arr[26];int j=0; for(int i=0;i<26;i++){ arr[i] =s[a+i]; } for(int i=2;i<28;i++){ if(h[i]==0){ for(j=u+1;j<b;j++){ if(s[j]-'?'==0) {arr[j-a]='A'+i-2;u=j;break;} } } } return string(arr); } int main() { in(); cin>>s; int n =s.length(); for(int x=0;x<n-25;x++){ memset(h,0,sizeof h); if(ch(x,x+26)) { for(int i=0;i<x;i++)if(s[i] == '?')cout<<"A";else cout<<s[i]; cout<<change(x,x+26); for(int i=x+26;i<n;i++)if(s[i] == '?')cout<<"A";else cout<<s[i]; return 0; } } cout<<-1; return 0; }

C Programming
TutorMe
Question:

You are given a matrix A that consists of N rows and M columns. Every number in the matrix is either zero or one. Calculate the number of such triples (i, j, h) where for all the pairs (x, y), where both x and y belong to [1; h] if y >= x, A[i+x-1][j+y-1] equals to one. Of course, the square (i, j, i+h-1, j+h-1) should be inside of this matrix. In other words, we're asking you to calculate the amount of square submatrices of a given matrix which have ones on and above their main diagonal. Input The first line of the input consists of two integers - N and M. The following N lines describe the matrix. Each line consists of M characters that are either zero or one. Output Output should consist of a single integer - the answer to the problem.

Bhanu T.
Answer:

#include <stdio.h> #include <stdlib.h> #include <memory.h> int min(int a, int b) { return (a > b) ? b : a; } int main(int argc, const char * argv[]) { int N, M; scanf("%d %d", &N, &M); char matrix[M * N]; int i; int j; for (i = 0; i < N; i++) { scanf("%s", &matrix[i * M]); } for (i = 0; i < N; i++) { for (j = 0; j < M; j++) { matrix[i * M + j] = matrix[i * M + j] - 48; } } long long total_count = 0; int tmp_count = 0; int sub_matrix_count[M]; memset(sub_matrix_count, 0, sizeof(int) * M); for (i = N - 1; i >= 0; i--) { for (j = 0; j < M; j++) { if (matrix[i * M + j] == 1) { ++sub_matrix_count[j]; } else { sub_matrix_count[j] = 0; } } tmp_count = 0; for (j = 0; j < M; j++) { tmp_count = min(tmp_count + 1, sub_matrix_count[j]); total_count += tmp_count; } } printf("%lld\n", total_count); return 0; }

Send a message explaining your
needs and Bhanu will reply soon.
Contact Bhanu
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.