diff --git a/December-01/C++_AminulIslam254.cpp b/December-01/C++_AminulIslam254.cpp new file mode 100644 index 0000000..96b3979 --- /dev/null +++ b/December-01/C++_AminulIslam254.cpp @@ -0,0 +1,49 @@ +#include + +using namespace std; + +typedef long long ll; + +ll fun1(vector s) +{ + ll i,count1=0; + char j; + ll n=s.size(); + ll a[26]={0}; + for(i=0;i s; + int i,n; + cout<< "Enter the no of elements"<>n; + cout<< "Enter the elements"<>temp1; + s.push_back(temp1); + } + cout< + +using namespace std; + +typedef long long ll; + +bool fun1(ll n) +{ + unordered_set s1; + while(1) + { + ll temp1=0; + while(n) + { + temp1+=((n%10)*(n%10)); + n/=10; + } + if(temp1==1) + { + return true; + } + if(s1.count(temp1)) + { + return false; + } + s1.insert(temp1); + n=temp1; + } +} + +int main() +{ + ll n; + cout<< "Enter the element"<>n; + if(fun1(n)) + { + cout<< "YES"< + +using namespace std; + +typedef long long ll; + + +int fun1(vector> a,string s,string name,ll i,ll j,ll r,ll c) +{ + if(s.length()>name.length()) + { + return 0; + } + if(i>=r) + { + return 0; + } + if(j>=c) + { + return 0; + } + if(s==name) + { + return 1; + } + int m1=(fun1(a,s+a[i][j],name,i,j+1,r,c)); + int m2=(fun1(a,s,name,i+1,j,r,c)); + int m3=(fun1(a,s,name,i,j+1,r,c)); + int m4=(fun1(a,s+a[i][j],name,i+1,j,r,c)); + return m1+m2+m3+m4; +} + +int main() +{ + ll r,c; + cout<< "Enter the no of rows"<>r; + cout<< "Enter the no of coloumns"<>c; + vector>a; + ll i,j; + cout<< "Enter elements"<temp1; + for(j=0;j>c; + temp1.push_back(c); + } + a.push_back(temp1); + } + string s=""; + string name; + cout<< "Enter name"<>name; + if(fun1(a,s,name,0,0,r,c)) + { + cout<< "YES"< + +using namespace std; + +typedef long long ll; + +int main() +{ + ll n1,n2,i; + cout<< "Enter the no of customers"<>n1; + cout<< "Enter the no of biscuits"<>n2; + queue customers,biscuits; + cout<< "Enter the customers preferances"<>var; + customers.push(var); + } + cout<< "Enter the biscuits types"<>var; + biscuits.push(var); + } + + ll ans=0; + while(!customers.empty()) + { + if(customers.front()==biscuits.front()) + { + customers.pop(); + biscuits.pop(); + } + else + { + queue temp1=customers; + bool flag=false; + while(!temp1.empty()) + { + if(temp1.front()==biscuits.front()) + { + flag=true; + break; + } + temp1.pop(); + } + if(flag) + { + customers.push(customers.front()); + customers.pop(); + } + else + { + break; + } + + } + } + if(!customers.empty()) + { + ans+=customers.size(); + } + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + string s; cin>>s; + vector posu; + vector post; + ll i; + for(i=0;i + +using namespace std; + +typedef long long ll; + +int main() +{ + ll n; + cout<< "Enter the no of buildings"<>n; + ll a[n][6],i,j; + cout<< "Enter coordinates"<>a[i][j]; + } + } + ll num,k; + cout<< "Enter the no of jet planes"<>num; + ll store1=0; + for(k=0;k>c; + cout<< "Enter axis number for x or y"<>axisnum; + for(i=0;iaxisnum) + { + isbig=true; + } + } + if(issmall && isbig) + { + store1++; + } + } + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + ll n; + cout<< "Enter the time"<>n; + ll a[n+1]={0},i,current1=3; + a[1]=3; + for(i=2;i<=n;i++) + { + if(a[i-1]==1) + { + current1*=2; + a[i]=current1; + } + else + { + a[i]=a[i-1]-1; + } + } + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + ll n,p,i; + cout<< "Enter the value of n and p"<>n>>p; + vector a; + cout<< "Enter array elements"<>var1; + a.push_back(var1); + } + sort(a.begin(),a.end()); + vector temp1; + for(i=0;i v1; + if(index==0) + { + for(i=0;i=p;i--) + { + v1.push_back(a[i]); + } + } + else + { + v1.push_back(a[index+1]); + ll left=index-1,right=index+1; + p=p-1; + while(p) + { + if(left==-1) + { + v1.push_back(a[right]); + right++; + } + else if(right==n) + { + v1.push_back(a[left]); + left--; + } + else + { + if((a[index]-a[left])<(a[right]-a[index])) + { + v1.push_back(a[left]); + left--; + } + else + { + v1.push_back(a[right]); + right++; + } + } + p--; + } + } + sort(v1.begin(),v1.end()); + ll num1=v1[v1.size()-1],ans=0; + for(i=v1.size()-2;i>=0;i--) + { + ans+=(num1-v1[i]); + } + cout< + +using namespace std; + +typedef long long ll; + +void fun1(vector> a,ll n,ll& count1,bool& isend,ll i,ll j,vector>& maze1) +{ + if(i==n) + { + return; + } + if(j==n) + { + return; + } + if(i==n-1 && j==n-1) + { + isend=true; + } + if(a[i][j]==1 && (!maze1[i][j])) + { + count1++; + + } + maze1[i][j]=true; + if(a[i][j]==-1) + { + return; + } + fun1(a,n,count1,isend,i+1,j,maze1); + fun1(a,n,count1,isend,i,j+1,maze1); +} + +int main() +{ + cout<< "Enter the no of rows and coloumns"<>n; + vector> a; + ll i,j; + cout<< "Enter the elements"< temp1; + for(j=0;j>var1; + temp1.push_back(var1); + } + a.push_back(temp1); + } + ll count1=0; + bool isend=false; + vector> maze1; + for(i=0;itemp2; + for(j=0;j + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the no of cars"<>n; + ll s1[n],i; + ll var1; + cout<< "Enter the speed of cars"<>s1[i]; + } + stack ans; + ans.push(s1[0]); + for(i=1;i0 && var1>0) || (ans.top()<0 && var1<0)) + { + ans.push(var1); + } + else + { + while(1) + { + ll curr=ans.top(); + if((abs(var1))>(abs(curr))) + { + ans.pop(); + } + else if((abs(var1))==(abs(curr))) + { + ans.pop(); + break; + } + else + { + break; + } + } + } + } + stack temp1; + while(!ans.empty()) + { + temp1.push(ans.top()); + ans.pop(); + } + while(!temp1.empty()) + { + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the no of diamonds"<>x; + vector mp,np; + ll i,var1; + cout<< "Enter the purity levels of all diamonds"<>var1; + mp.push_back(var1); + } + cout<< "Enter the minimum prices of all diamonds"<>var1; + np.push_back(var1); + } + cout<< "Enter the no of clients"<>z; + ll k[z],r[z],j; + cout<< "Enter the values of k"<>k[i]; + } + cout<< "Enter the values of r"<>r[i]; + } + ll ans=0; + for(i=0;ik[i] && np[j]<=r[i]) + { + ans++; + mp.erase(mp.begin()+j); + np.erase(np.begin()+j); + break; + } + } + } + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the no chapters"<>n; + ll a[n],i,sum1=0,j; + cout<< "Enter the no of concepts for each chapter"<>a[i]; + } + cout<< "Enter the value of x"<>x; + sort(a,a+n); + if(n==x) + { + cout<=0;i--) + { + ll time1=i+1; + sum1+=a[i+1]; + ll rem=sum1%a[i]; + if(rem==0) + { + time1+=(sum1/a[i]); + } + else + { + time1+=(sum1/a[i])+1; + } + bool flag=false; + if(time1>=x) + { + time1=i+1; + for(j=a[i]+1;j<=a[i+1];j++) + { + rem=sum1%j; + if(rem==0) + { + time1+=(sum1/j); + } + else + { + time1+=(sum1/j)+1; + } + if(time1 + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the no bracelts"<>x; + ll a[x],i,sum1=0,time1=0,max1=-1; + cout<< "Enter the array"<>a[i]; + sum1+=a[i]; + max1=max(max1,a[i]); + } + cout<< "Enter the value of n"<>n; + for(i=max1;;i++) + { + time1=sum1/i; + if(sum1%i!=0) + { + time1++; + } + if(time1<=n) + { + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the no of test cases"<>t; + while(t--) + { + ll x; + cout<< "Enter the no of rangers"<>x; + ll a[x],i; + cout<< "Enter the position of the rangers"<>a[i]; + if(a[i]%2==0) + { + even1++; + } + else + { + odd1++; + } + } + cout<< "Enter the position of leo"<>pos; + if(odd1==0 || even1==0) + { + cout<even1) + { + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the size for each task"<>n; + ll task_size[n],process_time[n],noof_task[n],i; + cout<< "Enter the elements for task size"<>task_size[i]; + } + cout<< "Enter the elements for processing time"<>process_time[i]; + } + cout<< "Enter the elements for no of tasks"<>noof_task[i]; + } + ll ans=0,time1=0; + for(i=0;i + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the size of matrix"<>n; + ll a[n][n],i,j; + ll pos[2][2],k=0; + cout<< "Enter the no of elements"<>a[i][j]; + if(a[i][j]==1) + { + pos[k][0]=i; + pos[k][1]=j; + k++; + } + } + } + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the size of matrix"<>n; + cout<< "Enter the courses"<> v1(n); + for(i=0;i>a1>>a2; + for(auto x:v1[a1]) + { + v1[i].insert(a2); + } + v1[a1].insert(a2); + + } + cout<< "Enter the size for the answer matrix"<>size1; + vector ans; + cout<< "Enter the elements for the answer matrix"<>a1>>a2; + if(v1[a1].count(a2)) + { + ans.push_back(true); + } + else + { + ans.push_back(false); + } + } + for(i=0;i + +using namespace std; + +typedef long long ll; + +int main() +{ + cout<< "Enter the value of n"<>n; + cout<< "Enter the size of the load"<>size1; + ll load[size1]; + cout<< "Enter the load of all the processes"<>load[i]; + } + int server[n]={0},j,count1[n]={0}; + for(i=0;ians) + { + ans=count1[i]; + index1=i; + } + } + cout< + +using namespace std; + +typedef long long ll; + +int main() +{ + + cout<< "Enter the value of x"<>x; + ll a[x][x],i,j,noof1s=0,noof0s=0; + cout<< "Enter the elements of array"<>a[i][j]; + if(a[i][j]) + { + noof1s++; + } + else + { + noof0s++; + } + } + } + ll var1=(x*x)/2; + ll var2=(x*x)-var1; + if(var1==noof0s && var2==noof1s) + { + ll col0=0,flag=0; + for(i=0;i + +using namespace std; + +typedef long long ll; + +void makegraph(vector> &v1,ll a,ll b) +{ + v1[a].insert(b); + v1[b].insert(a); +} + +void fun1(vector>& v1,ll head,ll &count1) +{ + for(auto x:v1[head]) + { + if(x==1) + { + count1++; + v1[head].erase(v1[head].begin()); + return; + } + else + { + fun1(v1,x,count1); + } + } + return; +} + +int main() +{ + + cout<< "Enter the value of x and y"<>x>>y; + vector> v1(y+1); + cout<< "Enter the values of a and b"<>a>>b; + makegraph(v1,a,b); + } + ll count1=0; + fun1(v1,1,count1); + cout<