Skip to content

Vishnu s reddy #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Basic Input and Output/Aman_And_Sharma.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
// Sample code to perform I/O:
#include <stdio.h>

int main(){
int num;
scanf("%d", &num); // Reading input from STDIN
printf("Input number is %d.\n", num); // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include<stdio.h>
int main()
{
int d,r,x,choc=0,i;
float dist,da;
scanf("%d",&d);
for(i=0;i<d;i++)
{
scanf("%d %d",&r, &x);
dist=(2*22*r)/7;
da=100*x;
if(da>=dist)
{
choc++;
}
}
printf("%d",choc);
}
18 changes: 18 additions & 0 deletions Basic Input and Output/Back_To_School.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
using namespace std;

int main()
{
int a,b,c;
cin>>a>>b>>c;
int max=c;
if(a>b && a>c)
{
max=a;
}
else if(b>c and b>a)
{
max=b;
}
cout<<max;
}
75 changes: 75 additions & 0 deletions Basic Input and Output/Cost_Of_Balloons.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
int num;
cin >> num; // Reading input from STDIN
cout << "Input number is " << num << endl; // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include <iostream>
using namespace std;

int main()
{
int num_test;
cin>>num_test;
for(int i=0;i<num_test;i++)
{
int green,purple;
cin>>green;
cin>>purple;
int suma=0,sumb=0;
int number_of_players;
cin>>number_of_players;
for(int j=0;j<number_of_players;j++)
{
int a,b;
cin>>a;
cin>>b;
suma=suma+a;
sumb=sumb+b;
}
if(suma>sumb)
{
if(green>purple)
{
cout<<((green*sumb)+(purple*suma))<<endl;
}
else
{
cout<<((green*suma)+(purple*sumb))<<endl;
}
}
else if(sumb>suma)
{
if(green>purple)
{
cout<<((green*suma)+(purple*sumb))<<endl;
}
else
{
cout<<((green*sumb)+(purple*suma))<<endl;
}
}
else
{
if(green>purple)
{
cout<<((green*suma)+(purple*sumb))<<endl;
}
else
{
cout<<((green*sumb)+(purple*suma))<<endl;
}
}
}
}
34 changes: 34 additions & 0 deletions Basic Input and Output/Count_divisors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
int num;
cin >> num; // Reading input from STDIN
cout << "Input number is " << num << endl; // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include<iostream>
using namespace std;

int main()
{
int a,b,c;
cin>>a>>b>>c;
int count=0;
for(int i=a;i<=b;i++)
{
if(i%c==0)
{
count++;
}
}
cout<<count;
}
42 changes: 42 additions & 0 deletions Basic Input and Output/Goki_And_His_Breakup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
int num;
cin >> num; // Reading input from STDIN
cout << "Input number is " << num << endl; // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include<iostream>
using namespace std;

int main()
{
int n,minskill;
cin>>n>>minskill;
int set[n];
for(int i=0;i<n;i++)
{
cin>>set[i];
}

for(int i=0;i<n;i++)
{

if(set[i]>=minskill)
{
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
}
72 changes: 72 additions & 0 deletions Basic Input and Output/Magical_Word.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
// Sample code to perform I/O:
#include <stdio.h>

int main(){
int num;
scanf("%d", &num); // Reading input from STDIN
printf("Input number is %d.\n", num); // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include <stdio.h>
int next(int n)
{
int i,ans;
int d1,d2;
int k[12]={67,71,73,79,83,89,97,101,103,107,109,113};
if(n<=67)
{
ans=67;
}
else if(n>=113)
{
ans=113;
}
else
{
for(i=0;i<12;i++)
{
if(k[i]>n)
{
d1=k[i]-n ;
d2=n-k[i-1];
if(d1<d2)
{
ans=k[i];
break;
}
else
{
ans=k[i-1];
break;
}
}
}
}
return ans;
}
int main()
{
int t,i,n;
int temp,ne;
char ch[500];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
scanf("%s",ch);
for(i=0;i<n;i++)
{
temp=ch[i];
ne=next(temp);
ch[i]=ne;

}
printf("%s\n",ch);
}
return 0;
}
48 changes: 48 additions & 0 deletions Basic Input and Output/Minimize_Cost.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<stdio.h>
#include<stdbool.h>
#include<malloc.h>

int min(int a, int b)
{
return a>b?b:a;
}
long long Solve (long long k, int* arr ,int n)
{
long long out = 0;
int i,j;
for (i=j=0; i<n ;i++)
{
if (arr[i]<=0)
continue;

while(i-j>k)
++j;
while(arr[i]!=0 && (i+k)>=min(n-1,j))
{
if(arr[j]>0)
{
j++;
continue;
}
int x = min(arr[i],abs(arr[j]));
arr[i]-=x;
arr[j]+=x;
if(arr[j]>=0)
j++;
}
}
for (i=0; i <n ;i++)
out += abs(arr[i]);
return out;
}

int main()
{
long long k;
int n,i_arr;
scanf("%d %lld", &n, &k);
int *arr = (int *)malloc(n*sizeof(int));
for(i_arr=0; i_arr<n; i_arr++)
scanf("%d", &arr[i_arr]);
printf("%lld", Solve(k, arr, n));
}
16 changes: 16 additions & 0 deletions Basic Input and Output/Palindromic_String.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'''
# Sample code to perform I/O:

name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT

# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''

# Write your code here
a=input()
b=a[::-1];
if(a==b):
print("YES");
else:
print("NO");
20 changes: 20 additions & 0 deletions Basic Input and Output/Prime_Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'''
You are given an integer N. You need to print the series of all prime numbers till N.
Input Format
The first and only line of the input contains a single integer N denoting the number till where you need to find the series of prime number.
Output Format
Print the desired output in single line separated by spaces.
Constraints
1<=N<=1000
'''


# Write your code here
n=int(input())
for i in range(2,n):
count=0
for j in range(1,i+1):
if(i%j==0):
count+=1
if(count==2):
print(i,end=" ")
Loading