#include <bits/stdc++.h> using namespace std; int main() { char s[140],charcter,l; int i,j; while(gets(s)) { for(i=0; s[i] != '\0'; ) { int freq = 0; while( (s[i] >='0' && s[i] <='9') ) { charcter = ( s[i++]-'0' ); freq += charcter;...
UVA Problem 488 Triangle Wave solution Solution
#include <bits/stdc++.h> using namespace std; int main() { int a,f,tc,i,j,k,l,m,n; scanf("%d",&tc); while(tc--) { cin>>a; cin>>f; for(l=1;l<=f;l++) { for(i=1;i<=a;i++) { for(j=0;j<i;j++) { cout<<i; } cout<<"\n"; }...
UVA Problem 11946 (Code Number Solution) Solution
#include <bits/stdc++.h> #include <string.h> using namespace std; int main() { int tc,i,j; char s[100],l; cin>>tc; getchar(); for(i=1;i<=tc;i++) { while(gets(s)!='\0') { l=strlen(s); if(l==0) { break; } for(j=0;j<l;j++) { if(s[j]=='3')...
UVA Problem 264 Count on Cantor Solution
#include <bits/stdc++.h> using namespace std; int main() { int N,i,j,insum,line; while(cin>>N) { insum=0; for(i=0;;i++) { insum+=i; if(insum >= N) { line = i; break; } } printf("TERM %d IS ", N); if(line&1)//insum-line...
UVA Problem 10189 Minesweeper Solution
#include <bits/stdc++.h> using namespace std; int main () { int n,m; int count=0; while(1) { cin>> m >> n; if (n ==0 && m ==0) break; count++; if (count > 1) cout << '\n'; int board[102][102] = {0}; for (int i=1; i<m+1;...
UVA Problem 12157 Tariff Plan Solution
#include <stdio.h> #include <bits/stdc++.h> using namespace std; int main() { int a,miles,juice,n,T,tc=1,b,c,i,arr,m,j,cells; cin>>T; for(int i=0;i<T;i++){ cin>>n; miles=0,juice=0; while(n--) { cin>>cells; miles...
UVA Problem 113 Power of Cryptography Solution
#include <bits/stdc++.h> using namespace std; int main() { double n,p,ans; while(cin>>n>>p) { printf("%.0lf\n",pow(p,1/n)); } return 0; }
UVA Problem 123 Searching Quickly Solution
#include <bits/stdc++.h> using namespace std; long long int reverse(long long int n) { long long int sum=0,r; while(n > 0) { 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...
UVA Problem 160 – Factors and Factorials Solutoin
#include<bits/stdc++.h> bool flag[100]; int List[100],primes[100]; int 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 j=i*i;...
UVA Problem 272 TEX Quotes Solution
#include <bits/stdc++.h> using namespace std; char s[200000]; int main() { int c=0,i; while(gets(s)) { for(i=0;i<strlen(s);i++) { if(s[i]=='"') { c++; if(c/2==0) printf("``"); else printf("''"); } else printf("%c",s[i]);; } printf("\n"); } return 0; }...
UVA Problem 299 train swap Solution
#include <bits/stdc++.h> using namespace std; int main() { int n, array[5000],k, c,count,d,T, t; while(cin>>T) { for(k=0;k<T;k++) { cin>>n; count=0; for (c = 0; c < n; c++) { cin>>array[c]; } for (c = 1 ; c <= n - 1; c++) { d =...
UVA problem 305 (Joseph – Page 2)solution
#include<bits/stdc++.h> using namespace std; int main() { int n,a[15]={0,2,7,5,30,169,441,1872,7632,1740,93313,459901,1358657,2504881}; while(cin>>n && n) { printf("%d\n",a[n]); } return 0; }...
UVA Problem 336 (A node to far Solution) Solution
#include<bits/stdc++.h> using namespace std; int tc=1,position=0; int bfs(int src, int TTL,map <int, vector<int> > edges) { map<int,int> visited,level; int unreach=0; queue<int>Q; Q.push(src); position=1; visited[src]=1;...
UVA problem 386 Perfect Cubes solution
#include <bits/stdc++.h> using namespace std; int main() { int a,b,c,d,n,i,j,k; for(n=6;n<=200;n++) { int a=n*n*n; for(i=2;i<=200;i++) { int b=i*i*i; for( j=i;j<n;j++) { int c = j*j*j; for( k=j;k<n;k++) { int d = k*k*k; if(a==(b+c+d)) {...
UVA Problem 406 Prime Cuts Solution
#include <stdio.h> #include<iostream> using namespace std; bool flag[1005]; int primes[1005]; int cnt; void seive(int n) { cnt=0; primes[cnt++] = 1; primes[cnt++]=2; for(int i=3; i<=n; i+=2) { if(flag[i] == 0) { primes[cnt++] = i; if(i...
UVA Problem 438 – The Circumference of the Circle Solution
#include<bits/stdc++.h> #include<math.h> #define pi 3.141592653589793 int main() { double x1,x2,y1,y2,x3,y3,a,b,c,s,radius,d,circle; while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3) != EOF) {...
UVA Problem 458 The Decoder Solution
#include <stdio.h> #include <string.h> int main() { char s[1000],l,i; while(gets(s)) { l=strlen(s); for(i=0;i<l;i++) printf("%c",s[i]-7); printf("\n"); } return 0; }
UVA Problem 483( Word Scramble) Solution
#include<stdio.h> #include<string.h> int main() { int l,i,j,b,k; char n[1000]; while(gets(n)) { l=strlen(n); b=-1; for(i=0;i<l;i++) { if(n[i]==' ') { for(j=i-1;j>b;j--) printf("%c",n[j]); printf(" "); b=i; } } for(i=l-1;i>b;i--)...
UVA Problem 492 Pig-Latin Solution
#include<bits/stdc++.h> using namespace std; bool vowel(char ch) { if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U') return true; else return false; } int main() { char...
UVA Problem 494 Kindergarten Counting GameSolution
#include <bits/stdc++.h> using namespace std; int main() { char s[2000]; int t,f,a,c; while(gets(s)) { c=0; for(t=0;s[t]!='\0';t++) { if( ((s[t]>='A' && s[t]<='Z') || (s[t]>='a' && s[t]<='z'))&&(s[t+1]<'a'||s[t+1]>'z')...
Laravel – Scopes (3 Easy Steps)
Scoping is one of the superpowers that eloquent grants to developers when querying a model. Scopes allow developers to add constraints to queries for a given model. In simple terms laravel scope is just a query, a query to make the code shorter and faster. We can...
CAMBRIDGE IELTS 17 TEST 3
READING PASSAGE 1: The thylacine Q1. carnivorous keywords: Looked like a dog had series of stripes ate, diet ate an entirely 1 .......................................... diet (2nd paragraph 3rd and 4th line) 1st and 2nd paragraph, 1st paragraph,resemblance to a...
Cambridge IELTS 16 Test 4
Here we will discuss pros and cons of all the questions of the passage with step by step Solution included Tips and Strategies. Reading Passage 1 –Roman Tunnels IELTS Cambridge 16, Test 4, Academic Reading Module, Reading Passage 1 Questions 1-6. Label the diagrams...
Cambridge IELTS 16 Test 3
Reading Passage 1: Roman Shipbuilding and Navigation, Solution with Answer Key , Reading Passage 1: Roman Shipbuilding and Navigation IELTS Cambridge 16, Test 3, Academic Reading Module Cambridge IELTS 16, Test 3: Reading Passage 1 – Roman Shipbuilding and...