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]);

375

Solution: radius of an inscribed circle of a  triangle r = (2 * area of triangle) /perimeter of triangle; #include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { int t; double B,H,R,d,a,b,r,h,c,l; double x; cin>>t; while(t–) { cin>>B>>H; l=H; h=H; a=(B/2)*(B/2); c=H*H; d=0; r=(B*H)/(B+2*sqrt(a+c)); R=r; while(r>=0.000001) { h-=2*r; d+=2*r; r=h/H*R; } printf("%13lf\n",d*M_PI);

389

#include <iostream> #include <string> #include <stdio.h> #include <sstream> using namespace std; int fBase,tBase; string str,str1; char ch[7]; int convert() { unsigned long long d; int k=7; unsigned long long r=0; unsigned long long _pow=1; if(str[str.size()-1]>'9') { d=str[str.size()-1]-55; } else d=str[str.size()-1]-'0'; //cout<<_pow<<" "<<d<<"\n"; r+=d; for(int i=str.size()-2;i>=0;i–) { _pow*=fBase; if(str[i]>'9') { d=str[i]-55; } else d=str[i]-'0'; //cout<<_pow<<" "<<d<<"\n";

343

#include <iostream> #include <string> #include <cstring> #include <string.h> using namespace std; unsigned long long decOf(string s,int a) { unsigned long long d; unsigned long long _pow=1; unsigned long long r=0; if((s[s.size()-1]-'0')>=0 && (s[s.size()-1]-'0')<=9) d=(s[s.size()-1]-'0'); else d=(s[s.size()-1]-55); if(d>=a) { return -1; } r+=(d*1); for(int i=s.size()-2;i>=0;i–) { _pow*=a; if((s[i]-'0')>=0 && (s[i]-'0')<=9) d=(s[i]-'0'); else d=(s[i]-55); if(d>=a) { return

340

#include <iostream> #include <map> #include <cstdlib> using namespace std; int target[1001]; int target_org[10]; int guess[1001]; int guess_org[10]; map<int,int> mp; int main() { int n,cnt; int match,w_match; int c=1,Ln; while(cin>>n) { if(n==0) break; int i=0; for(int i=1;i<=9;i++) target_org[i]=0; cnt=0; for(int i=1;i<=n;i++) { cin>>target[i]; if(target_org[target[i]]==0) { cnt++; } target_org[target[i]]++; } Ln=1; while(1) { int sum=0; match=0; for(int