Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
krajat0110 authored Oct 1, 2023
1 parent f578336 commit a8e1bd5
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
48 changes: 48 additions & 0 deletions jaildrunk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<iostream>
using namespace std;

int doorleft(int n){

int door[101];
for(int i=1;i<=100;i++){
door[i]=0;
}

for (int i=2; i<=n; i++){
for(int j =i; j<=n; j=j+i){

if(door[j] == 0){
door[j]=1;
}
else{
door[j]=0;
}
}
}

int count=0;

for(int i=1;i<=n;i++){
if(door[i] == 0){
count=count +1;
cout<<i<<" ";
}
else{
continue;
}
}
cout<<endl;
return count ;
}

int main(){

/*
int n;
cout<<"enter the no round ";
cin>>n;
*/

cout<<doorleft(100);

}
49 changes: 49 additions & 0 deletions matrixmultiply.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <bits/stdc++.h>
#include <climits>
#include <iostream>
using namespace std;
int mcm(int *q, int m)
{

n++;
int m[n][n];
int i, j, k, L, q;

for (i = 0; i < m; i++)
{
m[i][i] = 0;
}
for (L = 2; L < m; L++)
{

for (i = 1; i < m - L + 1; i++)
{
j = i + L - 1;
m[i][j] = INT_MAX;
for (k = i; k <= j - 1; k++)
{
q = m[i][k] + m[k + 1][j] + q[i - 1] * q[k] * q[j];
if (q < m[i][j])

m[i][j] = q;
}
}
}

return m[1][m - 1];
}

int main()
{

int m;
cin >> m;
int *q = new int[m];

for (int i = 0; i <= m; i++)
{
cin >> q[i];
}

cout << mcm(q, m);
}

0 comments on commit a8e1bd5

Please sign in to comment.