UVA Problem 543  Goldbach’s Conjecture Solution

UVA Problem 543 Goldbach’s Conjecture Solution

#include <stdio.h> #include<iostream> #include<math.h> using namespace std; int primes[]={2,3 ,5, 7, 11, 13, 17, 19, 23 ,29 ,31 ,37, 41, 43, 47 ,53 ,59 ,61, 67, 71, 73, 79, 83, 89, 97 ,101, 103, 107, 109, 113, 127 ,131, 137, 139, 149, 151 ,157 ,163,...

UVA Problem 575 – Skew Binary Solution

UVA Problem 575 – Skew Binary Solution

#include<bits/stdc++.h> using namespace std; int main() { char st[100]; long int a,i,j,ans,sum; while(scanf("%s",st)) { sum=0; j=strlen(st); for(i=0;i<j;i++) { a=st[i]-'0'; ans=a*(pow(2,j-i)-1); sum+=ans; } if(sum==0) break; cout<<sum<<endl; }...

UVA Problem 579(  Clock Hands) Solution

UVA Problem 579( Clock Hands) Solution

#include <bits/stdc++.h> using namespace std; int main() { float h,m,ans,i,j; while(scanf("%f:%f",&h,&m)==2) { if(h==0 and m==0) break;; i=h*30+(m/60)*30; j=m*6; ans=(i-j); if(ans<0) ans=ans*(-1); if (ans>180) ans=360-ans; printf("%.3lf\n",ans); }...

UVA Problem 583( Prime Factors ) Solution

UVA Problem 583( Prime Factors ) Solution

#include<bits/stdc++.h> bool flag[20000005]; int List[100000],primes[100000]; int listSize,cnt; using namespace std; void sieve(int n) { cnt=0; primes[cnt++] = 2; for(int i=3; i<=n; i+=2) { if(flag[i] == 0) { primes[cnt++] = i; if(i <= n/i) { for(int...

UVA Problem( Jumping Champion) 914 Solution

UVA Problem( Jumping Champion) 914 Solution

#include<bits/stdc++.h> #define MAX 1000008 using namespace std; bool flag[MAX]; int primes[MAX]; int cnt,a[2000]; void sieve(int n) { cnt=0; primes[cnt++] = 2; for(int i=3; i<=n; i+=2) { if(flag[i] == 0) { primes[cnt++] = i; if(i <= n/i) { for(int j=i*i;...

UVA Problem(Digit Counting) 1225 Solution

UVA Problem(Digit Counting) 1225 Solution

#include <bits/stdc++.h> using namespace std; int main() { int tc,i,num,k,j, A,B,C,D,E,F,G,H,I,J; cin>>tc; while(tc--) { A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0; cin>>num; for(i=1;i<=num;i++) { int s=i; for( k=1 ; ; k++) { int mod=s%10; if(mod==0)...

UVA Problem(Score) 1585 Solution

UVA Problem(Score) 1585 Solution

#include <bits/stdc++.h> using namespace std; int main() { string s; int n,i,score,sum,count; cin>>n; for(i=0;i<n;i++) { sum=0, count=0; cin>>s; for(int j=0;j<s.size();j++) { if(s[j]=='O') { count++; sum+=count; } if(s[j]=='X') { count=0; } }...

UVA Problem( Carmichael Numbers) 10006 Solution

UVA Problem( Carmichael Numbers) 10006 Solution

#include<bits/stdc++.h> using namespace std; int main() { int n; while(scanf("%d",&n)==1 && n) { if(n==561 || n==1105 || n==1729 || n==2465 || n==2821 || n==6601 || n==8911 || n==10585 || n==15841 || n==29341 || n==41041 ||n== 46657|| n== 52633||...

UVA Problem 10014 Solution

UVA Problem 10014 Solution

#include <bits/stdc++.h> using namespace std; int main() { double a0,an,a1,a,b,t,tc,n; double c[3002]; int i; cin>>t; while(t--) { b=0; cin>>n; cin>>a0>>an; if(n==0) printf("%0.2lf\n",an); else{ for( i=0;i<n;i++) { cin>>c[i];...

UVA Problem 10018 Solution

UVA Problem 10018 Solution

#include <bits/stdc++.h> using namespace std; long long int reverse(long long int n) { long long int sum=0,r; while(n) { r=n%10; sum=sum*10+r; n=n/10; } return sum; } int main() { long long int t, sum, count; int cse; cin >> cse; for (int i=0; i<cse;...

UVA Problem 10019 Solution

UVA Problem 10019 Solution

#include <bits/stdc++.h> using namespace std; int get_count (int n); int main() { int tc,i,j=0,n; cin>>tc; while(tc--) { scanf("%d",&n); printf("%d ",get_count(n)); char s[50]; sprintf(s, "%d" ,n); sscanf(s, "%x" ,&n); printf("%d\n",get_count(n));...

UVA Problem 10035 Solution

UVA Problem 10035 Solution

#include <bits/stdc++.h> using namespace std; int main() { long int a,b,x,y; while(cin >> a >> b) { if (a == 0 && b == 0) break; long int count=0,c=0; while( a > 0 || b > 0) { count = (a%10 + b%10 + count)/10; a/= 10; b /= 10; if...

UVA Problem 10041 Solution

UVA Problem 10041 Solution

#include <bits/stdc++.h> using namespace std; int a[502]; int main() { int i,j,t,n,sum; cin>>t; while(t--) { cin>>n; for(i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n); int v = a[n / 2]; sum = 0; for (int j = 0; j < n; j++) { sum += abs(v...

UVA Problem 10082 Solution

UVA Problem 10082 Solution

#include<stdio.h> #include<bits/stdc++.h> using namespace std; char s[100000]; int main() { long int i,L; while(gets(s)) { L=strlen(s); for(i=0;i<L;i++) { switch(s[i]) { case 'W': printf("Q"); break; case 'E': printf("W"); break; case 'R': printf("E");...

UVA Problem 10107 Solution

UVA Problem 10107 Solution

#include <vector> #include <stdio.h> #include <math.h> #include <iostream> #include <algorithm> using namespace std; int main() { int input,value; vector<int>myvector; if(myvector.empty()) while(cin>>input) {...

Chapter 4 Relational Algebra

Chapter 4 Relational Algebra

Relational Algebra The part of mathematics in which letters and other general symbols are used to represent numbers and quantities in formula and equations. Ex: (x + y) · z = (x · z) + (y · z). The main application of relational algebra is providing a theoretical...

Chapter 3 Components of the Database System Environment

Chapter 3 Components of the Database System Environment

Components of the Database System Environment There are five major components in the database system environment and their interrelationships are. Hardware Software Data Users Procedures Hardware:  The hardware is the actual computer system used for keeping and...