Posts

Showing posts from March, 2019

UVA 11332

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int main() {     char a[10],c[2]={'0','\0'};     int b=0,sum=0,sum1=0,sum2=0;     while(cin>>a)     {         if(strcmp(a,c)==0)             {break;}         else{             b=strlen(a);             sum=0;             for(int i=0; i<b; i++)             {                 if((a[i] >= '0') && (a[i] <= '9'))                 {                     sum=sum+(a[i]-'0');                 }             }             while(s...

UVA 11364

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int main() {     int a,b[20],c,d=0,sum=0;     cin>>a;     for(int i=0; i<a; i++)     {         cin>>c;         for(int j=0; j<c; j++)         {             cin>>b[j];         }         for(int j=0; j<c; j++)         {             for(int l=j+1; l<c; l++)             {                 if(b[j]>=b[l])                 {                     d=b[j];                     b[j]=b[l];                 ...

UVA 11875

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int main() {     int a,b[10],d;     double c;     cin>>a;     for(int i=0; i<a; i++)     {         cin>>c;         for(int j=0; j<c; j++)         {             cin>>b[j];         }         d=floor(c/2);         cout<<"Case "<<i+1<<": "<<b[d]<<endl;         d=0;     }     return 0; }

UVA 11799

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int main() {     int a,b,c,d=0;     cin>>a;     for(int i=0; i<a; i++)     {         cin>>b;         for(int j=0; j<b; j++)         {             cin>>c;             if(c>d)             {                 d=c;             }         }         cout<<"Case "<<i+1<<": "<<d<<endl;         d=0;     }     return 0; }

UVA 12149

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int main() {     int a=0,b[300],l=0,c;     for(int i=1; i<=200; i++)     {         a=a+(i*i);         b[l]=a;         l++;     }     while(cin>>c)     {         if(c==0)         {             break;         }         else         {             cout<<b[c-1]<<endl;         }     }     return 0; }

UVA 10235

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int status[100000000/32]; bool Check(int N,int pos){return (bool)(N & (1<<pos));} int Set(int N,int pos){    return N=N | (1<<pos);} int arr[1000000]; long long int l=0,a,b=1000000,n; void sieve() {      long long int i,j,sqrtN;      sqrtN = int( sqrt( b ) );      for( i=3; i<=sqrtN; i+=2 )      {          if( Check(status[i/32],i%32)==0)          {               for(j=i*i; j<=b; j+=2*i)              {                  status[j/32]=Set(status[j/32],j%32);               }          }     }     arr[0]=2;     l=1;      for(i=3;i<...

UVA 10948

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int status[100000000/32]; bool Check(int N,int pos){return (bool)(N & (1<<pos));} int Set(int N,int pos){    return N=N | (1<<pos);} int arr[1000000]; long long int l=0,a,b=1000000,n; void sieve() {      long long int i,j,sqrtN;      sqrtN = int( sqrt( b ) );      for( i=3; i<=sqrtN; i+=2 )      {          if( Check(status[i/32],i%32)==0)          {               for(j=i*i; j<=b; j+=2*i)              {                  status[j/32]=Set(status[j/32],j%32);               }          }     }     arr[0]=2;     l=1;      for(i=3;i<...

UVA 10924

Don't copy without trying #include<bits/stdc++.h> using namespace std; int status[100000000/32]; bool Check(int N,int pos){return (bool)(N & (1<<pos));} int Set(int N,int pos){ return N=N | (1<<pos);} int arr[100000]; long long int l=0,a,b=10000,n; void sieve() {      long long int i,j,sqrtN;      sqrtN = int( sqrt( b ) );      for( i=3; i<=sqrtN; i+=2 )      { if( Check(status[i/32],i%32)==0) { for(j=i*i; j<=b; j+=2*i) { status[j/32]=Set(status[j/32],j%32); } }     }     arr[0]=1;     arr[1]=2;     l=2;      for(i=3;i<=b;i+=2){             if(Check(status[i/32],i%32)==0){                 arr[l]=i;                 l++;         }      } } ...

UVA 686

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int status[100000000/32]; bool Check(int N,int pos){return (bool)(N & (1<<pos));} int Set(int N,int pos){    return N=N | (1<<pos);} int arr[100000]; long long int l=0,a,b=100000,n; void sieve() {      long long int i,j,sqrtN;      sqrtN = int( sqrt( b ) );      for( i=3; i<=sqrtN; i+=2 )      {          if( Check(status[i/32],i%32)==0)          {               for(j=i*i; j<=b; j+=2*i)              {                  status[j/32]=Set(status[j/32],j%32);               }       ...

UVA 294

Don't copy without trying. # include <bits/stdc++.h> using namespace std ; int status[ 100000000 / 32 ]; bool Check ( int N, int pos) { return ( bool )(N & ( 1 <<pos));} int Set ( int N, int pos) { return N=N | ( 1 <<pos);} long long int arr[ 10000000 ]; long long int l= 0 ,a,b= 31700 ,n; void sieve () { long long int i,j,sqrtN; sqrtN = int ( sqrt ( b ) ); for ( i= 3 ; i<=sqrtN; i+= 2 ) { if ( Check(status[i/ 32 ],i% 32 )== 0 ) { for (j=i*i; j<=b; j+= 2 *i) { status[j/ 32 ]=Set(status[j/ 32 ],j% 32 ); } } } arr[ 0 ]= 2 ; l= 1 ; for (i= 3 ;i<=b;i+= 2 ){ if (Check(status[i/ 32 ],i% 32 )== 0 ){ arr[l]=i; l++; } } } long long int p[ 1000000 ]; long long int e[ 1000000 ]; int nk= 0 ; void decomp ( long long int a) { long long int sqrtA= sqrt (a); for ( long long int i= 0 ; i<l ...

UVA 406

Don't copy without trying. #include<bits/stdc++.h> using namespace std; int status[100000000/32]; bool Check(int N,int pos){return (bool)(N & (1<<pos));} int Set(int N,int pos){    return N=N | (1<<pos);} int arr[1000]; long long int l=0,a,b=1000,n; void sieve() {      long long int i,j,sqrtN;      sqrtN = int( sqrt( b ) );      for( i=3; i<=sqrtN; i+=2 )      {          if( Check(status[i/32],i%32)==0)          {               for(j=i*i; j<=b; j+=2*i)              {                  status[j/32]=Set(status[j/32],j%32);               }   ...