#include <bits/stdc++.h> using namespace std; int main() { int v[10010]; //vector<int>v; int i,j,n,k,max,price1,a,price2,m,diff,tmp; while(cin>>n) { for(i=0;i<n;i++) cin>>v[i]; //v.push_back(i); cin>>m; max=1000000;...
UVA Problem 11152 Solution
#include <bits/stdc++.h> #define pi 2*acos(0) using namespace std; int main() { double s,a,b,c,tri_area,red_out,red_in; double area_circum,area_inscribed,area_triangle; while(scanf("%lf %lf %lf", &a, &b, &c)==3) { s=(a+b+c)/2;...
UVA Problem 11185 Solution
#include <stdio.h> int main() { long int dn,r,q; long int bn[10000],i,j; while(1) { scanf("%ld",&dn); if(dn<0) break; else if(dn==0) printf("0\n"); else { q=dn; i=0; while(q>0) { bn[i++]=q%3; q=q/3; } i=i-1; for(j=i;j>=0;j--) printf("%ld",bn[j]);...
UVa Problem 11192 Solution – Group Reverse
#include <bits/stdc++.h> using namespace std; int main() { char s[200]; int n,i,j,l,a; while(cin>>n) { if(n==0) break; scanf("%s",s); l=strlen(s); a=l/n; for(i = 0; i < l; i += a) { for(j = i+a-1; j >= i; j--) printf("%c",s[j]); } puts(""); }...
UVA Problem 11233 Solution – Deli Deli
#include <bits/stdc++.h> using namespace std; int main() { string ch1,ch2; map<string,string>m; int n,l,i,j,k; char c1,c2; cin>>l>>n; for(i=0;i<l;i++) { cin>>ch1>>ch2; m[ch1]=ch2; } for(i=0;i<n;i++){ cin>>ch2;...
UVA Problem 11332 Solution – Summing Digits
#include <bits/stdc++.h> using namespace std; int func_tion(int n) { int j,sum=0; if(n<10) return n; else { for(j=0;; j++) { sum+=n%10; n=n/10; if(n==0) break; } return func_tion(sum); } } int main() { int a,n,res,sum,k; while(cin>>n...
UVA Problem 11340 Solution – Newspaper
#include<stdio.h> #include<math.h> #include<string.h> #include<iostream> using namespace std; char ch1[10002]; int main() { int n,k,m,value[102],nn; char ch[302]; double s; scanf("%d",&n); while(n--) { s=0;...
UVA Problem 11344 Solution – The Huge One
#include <bits/stdc++.h> using namespace std; int main() { char m[1002]; int tc, l, n, i, j, r,sum,a[100]; bool flag; cin>>tc; while (tc--) { scanf("\r"); gets(m); l = strlen(m); cin>>n; for (i = 0; i < n; i++) cin>>a[i]; flag...
UVa Problem Solution 11371 – Number Theory for Newbies
#include <bits/stdc++.h> using namespace std; int main() { string n,a; long long s,b,c,d,l; while(cin>>n) { sort(n.begin(),n.end()); a=n; if(a[0]=='0') { for(int i=1;i<n.size();i++) { if(a[i]!='0') { swap(a[0],a[i]); break; } } }...
UVA Problem 11428 Solution – Cubes
#include <bits/stdc++.h> using namespace std; int main() { int n,a,b,i,j,x,y; bool penalty; while(cin>>n) { if(n==0) break; penalty=false; for(i=1;i<n;i++) { for(j=0;j<=i;j++) { if((i*i*i-j*j*j)==n) { cout<<i<<"...
Uva Problem Solution 11461 – Square Numbers
#include <bits/stdc++.h> using namespace std; int main() { long long int n,m,i,b,count; while(scanf("%lld %lld",&n,&m)==2) { if(n==0 && m==0) break; count=0; for(i=n;i<=m;i++) { b=sqrt(i); if(i==(b*b)) count++; }...
UVA Problem 11462 Solution – Age sort
#include <bits/stdc++.h> using namespace std; long int ary[2000007]; int main() { int n,i,j,k; while (scanf("%ld",&n)==1) { if (n==0) { break; } for (i=0;i<n;i++) { scanf("%ld",&ary[i]); } sort(ary,ary+n); for (i=0;i<n;i++) {...
UVa Problem Solution 11479 – Is this the easiest problem?
#include<stdio.h> int main() { long int t,a,b,c,i; while(scanf("%ld",&t)==1) { for(i=1; i<=t; i++) { scanf("%ld %ld %ld", &a, &b, &c); if ((a+b)<=c || (b+c)<=a || (c+a)<=b || a<=0 || b<=0 || c<=0) printf("Case %ld:...
UVA Problem 11494 Solution – Queen
#include <bits/stdc++.h> using namespace std; int main() { int x1,x2,y1,y2; while(cin>>x1>>y1>>x2>>y2) { if(x1==0 && y1==0 && x2==0 && y2==0) break; if(x1==x2 and y1==y2) printf("0\n"); else if(...
Uva problem Solution-11498 – Division of Nlogonia
#include <bits/stdc++.h> using namespace std; int main() { int tc,n,m,x,y; while(cin>>tc) { if(tc==0) break; cin>>n>>m; for(int i=0;i<tc;i++) { cin>>x>>y; if(x==n || y==m) cout<<"divisa\n"; else if(x>n and...
UVA Problem 11530 Solution – SMS Typing
#include<bits/stdc++.h> using namespace std; int main() { char l,s[105]; int c,j,t,i; scanf("%d%*c",&t); for(i=1;i<=t;i++) { c=0; gets(s); l=strlen(s); for(j=0;j<l;j++) {...
UVA Problem Solution11541 – Decoding
#include <bits/stdc++.h> using namespace std; int main() { int tc,cases=0,j,r; char s[1000],c; cin>>tc; while(tc--) { scanf("\r"); gets(s); int l=strlen(s); printf("Case %d: ",++cases); for(int i=0;i<l;i++) { r=0;...
UVA Problem 11547 Solution – Automatic Answer
#include <bits/stdc++.h> using namespace std; int main() { int t = 0,i,n; cin >> t; while(t--) { int n = 0; cin >> n; n *= 567; n /= 9; n += 7492; n *= 235; n /= 47; n-= 498; n/=10; n%=10; printf("%d\n",abs(n)); } return 0; }...
struct and union in C
struct and union in C These both declare same and uses are almost same; just the difference when use struct then need to declare with ‘struct’ keyword struct student { int roll; float age; }; when use union then declare as union student { int roll; float age;...
UVA Problem 11559 Solution – Event Planning
#include <bits/stdc++.h> using namespace std; int main() { int p,b,h,w,price,i,a,j,s; while(scanf("%d %d %d %d",&p,&b,&h,&w)==4) { int cost=15000000; for(i=0;i<h;i++) { scanf("%d",&price); for(j=0;j<w;j++) { scanf("%d",&a);...
Cambridge IELTS 15 Reading Test 3 Answers
PASSAGE 1: HENRY MOORE (1898 – 1986 ) QUESTIONS 1-7: DO THE FOLLOWING STATEMENTS AGREE WITH THE INFORMATION GIVEN IN READING PASSAGE 1? 1. Answer: TRUE Key words: leaving school, Moore, did, father, wanted It is mentioned in the first paragraph...
Cambridge IELTS 15 Reading Test 2 Answers
PASSAGE 1: COULD URBAN ENGINEERS LEARN FROM DANCE ? QUESTIONS 1- 6: READING PASSAGE 1 HAS SEVEN PARAGRAPHS, A-G. 1. Answer: B Key words: way of using dance, not proposing By using the skimming and scanning technique, we would find that before...
CAMBRIDGE IELTS 14 READING TEST 4 ANSWERS
PASSAGE 1: THE SECRET OF STAYING YOUNG QUESTIONS 1-8: COMPLETE THE NOTES BELOW. 1. ANSWER: FOUR / 4 Explain– Key words: focused age groups, ants– In paragraph 3, it is stated that “Giraldo focused on ants at four age ranges”,so the answer must be “four/4”....
CAMBRIDGE IELTS 14 READING TEST 3 ANSWERS
PASSAGE 1: THE CONCEPT OF INTELLIGENCE QUESTIONS 1-3: READING PASSAGE 1 HAS SIX PARAGRAPHS, A-F. 1. ANSWER: B Explain · Key words: non-scientists, assumptions, intelligence, influence, behavior · People‟s behavior towards...