0% found this document useful (0 votes)
20 views3 pages

Competitive Programing Cse 330

competitive programming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Competitive Programing Cse 330

competitive programming
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

--------------------------------------------

Name - Aniket Jha


Roll no- A24 according to excel sheet
KE158
SET -EVEN SET
------------------------------------------------
1.Return gift

#include <bits/stdc++.h>

using namespace std;


int main()
{
int t,i;
cin>>t;
for(i=0;i<t;i++){
int a,b,sum=0,temp;
int ani,fac,coun=0;
bool q=true;
cin>>a;
cin>>b;
sum=a+b;
temp=sum;

//for prime number


ani=0;
while(q){
coun++;

fac=0;
for(int j=1;j<=sum;j++){
if(sum%j==0){
fac++;
}
else{
continue;
}
}

if(fac==2)
{
if(coun==1){
sum=sum+1;
continue;
}
else{
q=false;

}
else{
sum=sum+1;
}
}
cout<<sum-temp<<endl;
}
}

--------------------------------------------

2.Separate No

#include <bits/stdc++.h>

using namespace std;

int main(){
int x;
cin >> x;
for(int a0 = 0; a0 < x; a0++){
string y;

cin >> y;

bool post=false;
long long int res=0;
if(y[0]=='0'){
string ny="0";
long long int sec=1;
while(ny.size()<y.size()){
ny+=to_string(sec);
sec++;
}

if(ny==y)
{
post=true;
}
}
else
{
for(int i=1;i<=(y.size()/2);i++){
res*=10;
res+=(y[i-1]-'0');
long long int sec=res+1;
string ny=y.substr(0,i);
while(ny.size()<y.size()){
ny+=to_string(sec);
sec++;
}
if(ny==y){

post=true;
break;
}
}
}
if(post&&y.size()>1)
{
cout<<"YES "<<res<<endl;
}
else
{

cout<<"NO"<<endl;

}
}
return 0;
}

You might also like