21BCS9185 Himanshu Bhardwaj It Day1
21BCS9185 Himanshu Bhardwaj It Day1
21BCS9185 Himanshu Bhardwaj It Day1
Code:
#include <bits/stdc++.h>
int main() {
int a ,b;
cin>>a>>b;
else cout<<"https://www.codechef.com/practice";
OUTPUT:
Q2: Fire and Ice Problem
Code:
#include <bits/stdc++.h>
string ans;
int carry = 0;
int x = s1.size()-1;
int y = s2.size()-1;
if(x>=0){
carry+=s1[x]-'0';
x--;
if(y>=0){
carry+=s2[y]-'0';
y--;
}
ans.push_back(carry%10+'0');
carry/=10;
reverse(ans.begin(),ans.end());
return ans;
int main() {
vector<string>f(1001);
f[1]=f[2]="1";
for(int i=3;i<=1000;i++){
f[i]=func(f[i-1],f[i-2]);
int t;
cin>>t;
while(t--){
int n,m,ans=0;
cin>>n>>m;
for(auto &i:f[n]){
ans=(ans*10)+(i-'0');
ans%=m;
ans=(ans*2)%m;
cout<<ans<<'\n';
return 0;
OUTPUT:
Q3: WildCard Matching Problem
Code:
bool solve(string s,string p,int i,int j ,vector<vector<int>> &dp){
return true;
return false;
}
if(p[j]=='?' || s[i]==p[j]){
else if(p[j]=='*'){
return dp[i][j]=false;
int n= s.size();
dp[0][0] = true;
for(int i=1;i<=n;i++){
dp[i][0]=false;
for(int j=1;j<=m;j++){
for(int k = 1;k<=j;k++){
if(p[k-1]!='*'){
flag = false;
break;
dp[0][j] = flag;
for(int i=1;i<=n;i++){
for(int j =1;j<=m;j++){
if(p[j-1]=='?' || s[i-1]==p[j-1]){
dp[i][j] = dp[i-1][j-1];
else if(p[j-1]=='*'){
dp[i][j] = dp[i][j-1] || dp[i-1][j];
else
dp[i][j]=false;
return dp[n][m];
OUTPUT:
CODE:
#include <iostream>
void solve(){
int nd,xd;
cin>>nd;
int ad[3]={0};
cin>>xd;
if(xd==1 || xd==2){
ad[0]++;
ad[1]++;
}else{
ad[2]++;
int main() {
int t;
cin>>t;
while(t--){
solve();
return 0;
OUTPUT:
Q5: Sum of digits Problem
CODE:
#include <iostream>
int sum = 0;
while(num > 0) {
num /= 10;}
return sum;
int main() {
int T;
cin >> T;
while (T--) {
int num;
return 0;
OUTPUT:
CODE:
#include <bits/stdc++.h>
int main() {
int t;
cin>>t;
while(t--)
bool ans=true;
int k;
cin>>k;
while(k--){
bool upper=false,lower=false;
for(int i=0;i<s.length();i++){
upper=true;
lower=true;
else
ans=false;
ans=false;
if(ans)
cout<<"YES\n";
else
cout<<"NO\n";
return 0;
OUTPUT:
class Solution {
public:
int calculate(string s) {
int num = 0;
int rst = 0;
int sign = 1;
for (char c : s) {
if (isdigit(c)) {
else {
num = 0;
if (c == '+') sign = 1;
if (c == '(') {
nums.push(rst);
ops.push(sign);
rst = 0;
sign = 1;
ops.pop(); nums.pop();
};
OUTPUT:
CODE:
class Solution {
private:
if(n == 0){
return 1;
ans *= ans;
ans %= mod;
if(n%2==1){
ans *= x;
ans %= mod;
return ans;
public:
};
OUTPUT: