#include <iostream> #include <vector> #include <algorithm> #include <fstream> using namespace std; int pre[10001]; int in[10001]; ofstream wrt; int search(int _in[],int a,int len) { for(int i=0;i<len;i++) { if(_in[i]==a) return i; } return -1; } void printPostOrder(int _in[],int _pre[],int n) { int root=search(_in,_pre[0],n); if(root!=0) printPostOrder(_in,_pre+1,root); if(root!=n-1) printPostOrder(_in+root+1,_pre+root+1,n-root-1); cout<<_pre[0]<<"\n"; //wrt<<_pre[0]<<"\n"; } int main() { int i=0; int a;
Author: Asif Naeem
12376
#include <iostream> #include <vector> #include <queue> using namespace std; int value[104]; vector<int> vb[104]; int visit[104]; queue<int> ue; int learned; int _next; int findAns(int a) { int _max=0; if(vb[a].size()==0) { _next=a; //learned+=value[a]; return 0; } else { for(int i=0;i<vb[a].size();i++) { if(value[i]]>_max) { _max=value[i]]; _next=vb[a][i]; } } learned+=_max; return findAns(_next); } return 0; } int main() {
12372
#include <iostream> using namespace std; int main() { int t,l,w,h; int c=1; cin>>t; while(t–) { cin>>l>>w>>h; if(l>20 || w>20 || h>20) cout<<"Case "<<c++<<": bad\n"; else cout<<"Case "<<c++<<": good\n"; } return 0; }
12397
#include <iostream> #include <stdio.h> #include <math.h> #include <string> #include <map> using namespace std; map<int,char> mp; int main() { int n,p; string str; mp[1]='I'; mp[5]='V'; mp[10]='X'; mp[50]='L'; mp[100]='C'; mp[500]='D'; mp[1000]='M'; //mp[2]= while(cin>>n) { str=""; int cnt=0; p=0; if(n>=1000) { p=n/1000; cnt+=p*4; n-=1000*p; } p=0; if(n>=100) { p=n/100; if(p==1) cnt+=2; else if(p==2) cnt+=4; else if(p==3) cnt+=6; else
306
#include <iostream> #include <map> #include <vector> #include <string> #include <stdio.h> /* 10 4 5 3 7 2 8 1 6 10 9 1 Hello Bob 1995 CERC 0 0 Sample Output BolHeol b C RCE */ using namespace std; int arr[202]; vector<char> c_arr[202]; char s[202]; int cycle(int pos) { int org=pos; int init=arr[pos]; int cnt=1;
12342
#include <iostream> #include <stdio.h> #include <math.h> using namespace std; double _max(double a,double b) { if(a>b) return a; else return b; } int main() { int t,c=1; double a,b,cx; cin>>t; while(t–) { cin>>a; if(a<=180000) { cout<<"Case "<<c++<<": "<<0<<"\n"; continue; } cx=0; if((a-1180000)>0) { cx+=(a-1180000)*.25; a-=(a-1180000); } if((a-880000)>0) { cx+=(a-880000)*.2; a-=(a-880000); } if((a-480000)>0) { cx+=(a-480000)*.15; //cout<<"dd1 "<<(a-480000)<<"\n";
355
#include <string> #include <stdio.h> #include <sstream> #include <iostream> using namespace std; int fBase,tBase; string str,str1; char ch[200]; int k; int convert() { unsigned long long d; unsigned long long r=0; unsigned long long _pow=1; if(str[str.size()-1]>'9') { d=str[str.size()-1]-55; if(d>=fBase) return -1; } else { d=str[str.size()-1]-'0'; if(d>=fBase) return -1; } //cout<<_pow<<" "<<d<<"\n"; r+=d; for(int i=str.size()-2;i>=0;i–) { _pow*=fBase;
356
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { double n,m,d1,d2; int cnt,n_cnt,c=0; while(cin>>n) { m=(n-0.5)*(n-0.5); cnt=0; n_cnt=0; for(int i=0;i<=n;i++) { for(int j=0;j<=n;j++) { d1=i*i+j*j; d2=(i+1)*(i+1)+(j+1)*(j+1); if(d1<m && d2<=m) { //cout<<i<<" "<<j<<" "<<i+1<<" "<<j+1<<"\n"; cnt++; } else if(d1<m && d2>m) n_cnt++; } } if(c) cout<<"\n"; c=1; cout<<"In the case n = "<<n<<",
378
#include <cmath> #include <iostream> #include <stdio.h> #define INF 1000000000 using namespace std; int n; int c=1; double m1,m2,d,d1,d2,x1,x2,x3,x4,y_1,y2,y3,y4,c1,c2; double px,py; void intersect() { if(x1!=x2) { m1=((y_1-y2)/(x1-x2)); } else { m1=INF; } if(x3!=x4) m2=(y3-y4)/(x3-x4); else m2=INF; if(m1==INF) c1=0; else c1=y_1-m1*x1; if(m2==INF) c2=0; else c2=y3-m2*x3; if(m1==INF) { px=x1; if(m2==0) { py=y3; printf("POINT %.2lf %.2lf\n",px,py); return; } else
341
#include <iostream> #include <stdio.h> #include <vector> #define inf 1000000000 using namespace std; vector<int> v; int path[11][11]; int NExt[11][11]; bool first; /* void find_path(int a,int b) { v.push_back(b); while(NExt[a][b]!=-1) { v.push_back(NExt[a][b]); b=NExt[a][b]; } v.push_back(a); } */ void find_path(int i,int j) { if(NExt[i][j]==-1) if(first) { cout<<i<<" "<<j; first=false; } else { cout<<" "<<j; } else { find_path(i,NExt[i][j]);