11909

#include <iostream> #include <cmath> #include <cstdio> #define PI acos(-1) using namespace std; //using the formulae a/sin A = b/sin B = c/sin C int main() { double L,W,H,angle; double changed_hight,res,changed_base,empty_area; while(scanf("%lf%lf%lf%lf",&L,&W,&H,&angle)!=EOF) { changed_hight= sin(angle*PI/180)*L/sin((90-angle)*PI/180); if(angle==0) { printf("%.3lf mL\n",L*W*H); } else if(angle==90) { printf("%.3lf mL\n",0); } else if(changed_hight<=H) { empty_area=changed_hight*L*W/2; res = L*W*H-empty_area; printf("%.3lf mL\n",res); }

1208

#include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <string> #include <sstream> #include <algorithm> using namespace std; struct Edge{ int source,destination,weight; }; //to keep track of parent and rank of union find struct subset{ int parent; int rank; }; bool graph[100][100]; vector<Edge> edges; subset* subsets; bool cmp(Edge a,Edge b) { return a.weight<b.weight; } int find(int

10209

To get accepted I had to use PI = acos(-1). Lets assume X = middle portion; Y = dotted region; Z = stripped region; Three independent equations are: X+ 4*Y + 4*Z = a*a……………………………………………….(1) Y + 2*Z = a*a – PI*a*a/4………………………………………..(2) X/2 + Y + Z/2 = (PI*a*a)/4 – ΔPAR………………………..(3) #include <iostream> #include <cstdio> #include <cstdio>

12779

#include <stdio.h> #include <iostream> #include <math.h> using namespace std; #define eps 1e-6 #define MX 1000000000 #define ll long long struct POINT{int x,y;}; long long gcd(ll a,ll b) { if(a%b==0) return b; else return gcd(b,a%b); } POINT pp[4]; bool find_perp_distance(POINT u,POINT v,POINT s,ll &B,ll &C,double &val) { //form equation of st line uv (ax+by+c=0) double a,b,c,r;

11824

#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <cstdlib> #include <algorithm> #define LMT 5000000 #define ll long long using namespace std; bool cmp(int a,int b) { return a>b; } ll _pow(int a,int p) { ll ans=1; while(p–) { ans=ans*a; if(ans>=LMT) return LMT; } return ans; } int main() { vector<int>

10188

#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <cmath> #include <cstdlib> using namespace std; string s,ans; string str,str1; int n,m; bool accept() { if(n!=m) return 0; if(str==str1) return 1; return 0; } bool presentation() { string num1="",num2=""; for(int i=0;i<str.size();i++) { if(isdigit(str[i])) num1.append(1u,str[i]); } for(int i=0;i<str1.size();i++) { if(isdigit(str1[i])) num2.append(1u,str1[i]); } if(num1==num2)

11917

#include <iostream> #include <cstdio> #include <sstream> #include <string> #include <map> using namespace std; int main() { int t,n,d,D; scanf("%d",&t); string sub,s; int kase=1,res; while(t–) { scanf("%d",&n); map<string,int> mp; for(int i=1;i<=n;i++) { cin>>s; scanf("%d",&d); mp[s]=d; } scanf("%d",&D); cin>>sub; res = mp[sub]; if(res==0 || res>(D+5)) printf("Case %d: Do your own homework!\n",kase++); else if(res>D && res<=(D+5)) printf("Case %d:

1282

Theory: The idea for solving the problem is: for any fibonacci word F(n) = F(n-1)+F(n-2) = F(n-2)+F(n-3)+F(n-2), so word F(n-2) is both suffix and prefix of word F(n). After observing a little more we can find that F(n-2) will always be the prefix for all the rest of the fibonacci word.Now find the minimum F(n-3)

11475

#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <cstdlib> #define INF 1000000 #define ll long long using namespace std; int main() { char s[100005]; string str; int len,i,j,idx; int *failureFunc; while(scanf("%s",s)!=EOF) { len=strlen(s); str=""; for(int y=len-1;y>=0;y–) str.append(1u,s[y]); failureFunc=(int *)malloc(sizeof(int)*len); failureFunc[0]=0; i=0; j=1; while(j<len) { if(str[i]==str[j]) { i+=1; failureFunc[j]=i; j+=1; }