#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() { int t,kase=1; double r,len,width; double up_left_x,up_left_y,up_right_x,up_right_y,lo_right_x,lo_right_y,lo_left_x,lo_left_y; scanf("%d",&t); while(t–) { scanf("%lf",&r); len = r/.2; width = len*.6; up_left_x = (-len)*.45; up_left_y = width/2; up_right_x = (len)*.55; up_right_y = width/2;
Category: Algorithm
11715
#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() { int kase=1; int n; double u,v,t,a,s; while(scanf("%d",&n),n) { if(n==1) { scanf("%lf%lf%lf",&u,&v,&t); a = (v-u)/t; s=u*t+.5*a*(t*t); printf("Case %d: %.3lf %.3lf\n",kase++,s,a); } else if(n==2) { scanf("%lf%lf%lf",&u,&v,&a); t = (v-u)/a; s=u*t+.5*a*(t*t);
11428
#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <cstdlib> #define INF 1000000 #define ll long long using namespace std; struct node{ int x,y; }; node arr[10005]; int main() { int n,diff; int difference_arr[10005]; for(int i=2;i<61;i++) { for(int j=1;j<i;j++) { diff = i*i*i – j*j*j; if(diff>10001) continue; difference_arr=1; if(arr.x==0 || arr.y==0)
10101
#include <iostream> #include <cstdio> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <cstdlib> #define INF 1000000 #define ll long long using namespace std; string ans; int i=0; void check() { if(ans.size()) ans.append(1u,' '); } void banglaNumb(string s) { int len = s.size(); if(len>=8) { check(); ans.append(1u,s[i++]); ans.append(" kuti"); } if(len>=7) { if(s[i]!='0') { check();
11402
#include <iostream> #include <cstdio> #include <cstring> #include <string> #define sz 1024001 #define INV 1 #define SET 2 #define RESET 3 using namespace std; struct segment{ int pending_op_typ; int sum; int left,right; int len; }; segment tree[sz*4]; string ss; void init(int node,int b,int e) { tree[node].len = e-b+1; tree[node].left=b; tree[node].right=e; tree[node].pending_op_typ=0; if(b==e) { if(ss[b]=='1') tree[node].sum=1; else
12436
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #define ll long long #define sz 250005 using namespace std; struct segment{ ll left,right; ll len; ll first_inc,last_inc; ll totalAB; bool isSetvalue; ll cary; ll sum; }; segment arr[sz*4]; void changeAB(ll frist_incr,ll last_incr,int node,ll step) { arr[node].totalAB += step; arr[node].first_inc += frist_incr; arr[node].last_inc += last_incr;
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;