#include <iostream> using namespace std; int main() { int a,b,c; while(cin>>a) { cin>>b>>c; if(a==b &&b==c) { cout<<"*\n"; continue; } if(a!=b && a!=c) { cout<<"A\n"; continue; } if(b!=a && b!=c) { cout<<"B\n"; continue; } if(c!=b && a!=c) { cout<<"C\n"; continue; } } return 0; }
Author: Asif Naeem
12770
#include <iostream> #include <string> #include <string.h> #include <map> using namespace std; map<char,int> mp; int main() { string str; while(cin>>str) { if(str=="#") break; mp.clear(); for(int i=0;i<str.size();i++) { mp[str[i]]+=1; } if(mp.size()==1) { cout<<"\n"; continue; } int k=0; map<char,int> m; for(map<char,int>::iterator i=mp.begin();i!=mp.end();++i) { if((i->second)%2!=0) { k++; m[i->first]=1; } } int s=0; for(map<char,int>::iterator i=m.begin();i!=m.end();++i) { if(s==k-1) break; s++; cout<<i->first;
12708
#include <iostream> using namespace std; int main() { int t; unsigned long long n; cin>>t; while(t–) { cin>>n; cout<<n/2<<"\n"; } return 0; }
10042
#include <iostream> #include <string> #include <vector> #include <string.h> using namespace std; int prime[1000001]; vector <long long> vb; long long sumof(long long a) { long long l=0; while(a) { l+=a%10; a/=10; } return l; } int isPrime(long long n) { if(n<1000001) { if(prime[n]==0) return 1; else return 0; } for(int i=2;i*i<=n;i++) if(n%i==0) return 0; return 1;
536
Tree Recursion #include <iostream> #include <stdio.h> #include <string.h> #include <string> using namespace std; // A utility function to search x in arr[] of size n int search(char arr[], char x, int n) { for (int i = 0; i < n; i++) if (arr[i] == x) return i; return -1; } // Prints postorder traversal
10334
Its a fibonicci series solution. I dont know why….But found that it shows the similiarity. #include <iostream> #include <vector> using namespace std; int fib[2000][5000]; vector<int> vb[2001]; int main() { fib[0][0]=1; fib[1][0]=2; fib[2][0]=3; int c=0; for(int i=3;i<2000;i++) { for(int j=0;j<5000;j++) { int t=fib[i-1][j]+fib[i-2][j]+c; fib[i][j]=t%10; c=t/10; } } //cout<<fib[3][0]; vb[0].push_back(1); vb[1].push_back(2); vb[2].push_back(3); for(int i=3;i<2000;i++) { int f=0;
12289
#include <iostream> #include <string> #include <vector> #include <string.h> using namespace std; int main() { int n; string str; cin>>n; while(n–) { cin>>str; if(str.size()==5) { cout<<"3"<<"\n"; continue; } int cnt=0; if(str[0]=='o'|| str[0]=='n' || str[0]=='e') { cnt++; } if((str[1]=='o'|| str[1]=='n' || str[1]=='e') && str[1]!=str[0]) { cnt++; } if((str[2]=='o'|| str[2]=='n' || str[2]=='e') && str[1]!=str[2] && str[2]!=str[0]) { cnt++;
10183
#include <iostream> #include <string> #include <vector> #include <string.h> using namespace std; int fib[600][1000]; vector <int> fibo[600]; int iSBig(int i,string s) { if(fibo[i].size()>s.size()) return 1; if(fibo[i].size()<s.size()) return 0; for(int j=0;j<s.size();j++) { if((s[j]-'0')<fibo[i][j]) { return 1; } if((s[j]-'0')>fibo[i][j]) { return 0; } } return 1; } int iSSmall(string s,int i) { if(fibo[i].size()>s.size()) return 0; if(fibo[i].size()<s.size()) return 1;
10088
[highlight]Theory[/highlight] Picks formulae ::: ans=area of polygon-B/2+1; Given a polygon whose vertices are of integer coordinates (lattice points), count the number of lattice points within that polygon.Pick’s theoreom states that where; is the area of the polygon. is the number of lattice points on the exterior Area of a polygon: First, number the vertices in
846
#include <iostream> #include <math.h> using namespace std; //long long diff[10001]; long long int m,n,d; int main() { int t; cin>>t; while(t–) { cin>>m>>n; d= m-n; if(d<0) d=d*(-1); if(d==0) { cout<<0<<"\n"; continue; } if(d==1) { cout<<1<<"\n"; continue; } if(d==2) { cout<<2<<"\n"; continue; } if(d==3) { cout<<3<<"\n"; continue; } long long int r= sqrt(d); if(r<0) r*=-1; if(d==r*r)