Problem:
Problem A: The Mean of Angles
Problem
与えられた2つの角度
θ
1
,
θ
2
のちょうど間の角度を求めよ。ここで、ちょうど間の角度を、下図のように「
θ
1
+
t
=
θ
2
−
t
を満たす
t
のうち絶対値が最も小さいものを
t’
としたときの
θ
1
+
t’
」と定義する。
Input
入力は以下の形式で与えられる。
θ
1
θ
2
Constraints
入力は以下の条件を満たす。
角度は度数法(degree)で表される
0 ≤
θ
1
,
θ
2
< 360
θ
1
,
θ
2
は整数
|
θ
1
−
θ
2
| ≠ 180
解答が[0,0.0001]または[359.999, 360)になるような入力は与えられない
Output
θ
1
,
θ
2
のちょうど間の角度を度数法で[0,360)の範囲で1行に出力せよ。ただし0.0001を超える誤差を含んではならない。
Sample Input 1
10
20
Sample Output 1
15.0
Sample Input 2
20
350
Sample Output 2
5.0

Submitted solutions:

code_snippet: #include<iostream>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<complex>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define EPS (1e-5)
#define equals(a,b) (fabs((a)-(b))<EPS)
double a,b;

bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {
  double ans = 1000;
  for(long long t=0;t<=36000000LL;++t) {
    double v = (double)( t / 100000.0 );
    double da = a + v;
    double db = b - v;
    if( LTE(360,da) ) da -= 360.0;
    if( LTE(360,db) ) db -= 360.0;
    if( LT(da,0) ) da += 360.0;
    if( LT(db,0) ) db += 360.0;
    if( equals(da,db) && LT(da,ans) ) {
      ans = da;
    }
  }
  printf("%.10f\n",ans);
}

int main(){
  cin >> a >> b;
  compute();
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 230
memory_kb: 3200
final_rank: 12

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(long double a,long double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(long double a,long double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  long double a,b;
  cin >> a >> b;
  long double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    long double t = tt/10000.0;
    long double v = a + t;
    long double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmodl(v,360);
    w = fmodl(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmodl(t,360);
      else {
	if( LT(fabs(t),fabs(ans)) ) { // t < ans
	  ans = t;
	}
      }
    }
  }
  printf("%.10Lf\n",fmodl(ans+a,360));
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 430
memory_kb: 3348
final_rank: 5

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(long double a,long double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(long double a,long double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  long double a,b;
  cin >> a >> b;
  long double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    long double t = tt/10000.0;
    long double v = a + t;
    long double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmodl(v,360);
    w = fmodl(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(t,360);
      else {
	if( LT(fabs(t),fabs(ans)) ) { // t < ans
	  ans = t;
	}
      }
    }
  }
  printf("%.10Lf\n",fmod(ans+a,360));
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 340
memory_kb: 3348
final_rank: 4

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    double t = tt/10000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(t,360);
      else {
	if( LT(fabs(t),fabs(ans)) ) { // t < ans
	  ans = t;
	}
      }
    }
  }
  assert( !equals(ans,-1));
  printf("%.10f\n",fmod(ans+a,360));
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 90
memory_kb: 3260
final_rank: 2

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-5)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -36000000;tt<=36000000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(t,360);
      else {
	if( LT(fabs(fmod(t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(t,360);
	}
      }
    }
  }
  printf("%.10f\n",fmod(ans+a,360));
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 880
memory_kb: 3348
final_rank: 8

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -36000000;tt<=36000000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(t,360);
      else {
	if( LT(fabs(fmod(t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(t,360);
	}
      }
    }
  }
  printf("%.10f\n",fmod(ans+a,360));
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 990
memory_kb: 3300
final_rank: 7

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    double t = tt/10000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(t,360);
      else {
	if( LT(fabs(fmod(t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(t,360);
	}
      }
    }
  }
  printf("%.10f\n",fmod(ans+a,360));
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 90
memory_kb: 3348
final_rank: 3

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -36000000;tt<=36000000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(t,360);
      else {
	if( LT(fabs(fmod(t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(t,360);
	}
      }
    }
  }
  printf("%.10f\n",ans+a);
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 950
memory_kb: 3292
final_rank: 6

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    double t = tt/10000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(t,360);
      else {
	if( LT(fabs(fmod(t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(t,360);
	}
      }
    }
  }
  printf("%.10f\n",ans+a);
  return 0;
}
accuracy: 0.21951219512195122
time_ms: 80
memory_kb: 3260
final_rank: 1

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

bool sim = false;

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    double t = tt/10000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    if( LT(w,0) ) w += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(a+t,360);
      else {
	if( LT(fabs(fmod(a+t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(a+t,360);
	}
      }
    }
  }
  printf("%.10f\n",ans);
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 80
memory_kb: 3268
final_rank: 16

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

int main() {
  double a,b;
  cin >> a >> b;
  //rep(i,360) rep(j,360) {
  //a = i;
  // b = j;
  double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(a+t,360);
      else {
	if( LT(fabs(fmod(a+t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(a+t,360);
	}
      }
    }
  }
  //cout << "a = " << i << ", b = " << j << " = ";
  if( LT(ans,0) ) ans += 360.0;
  printf("%.10f\n",ans);
  //}
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 70
memory_kb: 3264
final_rank: 14

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -36000000;tt<=36000000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(a+t,360);
      else {
	if( LT(fabs(fmod(a+t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(a+t,360);
	}
      }
    }
  }
  if( LT(b,a) ) {
    printf("%.10f\n",360.0-ans);
  } else {
    printf("%.10f\n",ans);
  }
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 780
memory_kb: 3216
final_rank: 18

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
#include <assert.h>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 150005
#define EPS 0.000000001
using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    double ans=INF;
    vector<pair<double,int>>ty;
    for(long long int i = -36000000;i<=36000000;++i){
        double t=i/100000.0;
        double v=(a+t);
        double w=(b-t);
        double s,u;
        int num=(int)v,hoge=(int)w;
        s=v-num; u=w-hoge;
        num%=360; hoge%=360;
        v=s+num; w=u+hoge;
        if(abs(v-w)<EPS){
            int flag; if(t>0)flag=1;
            else flag=0;
            ty.push_back(pair<double,int>(abs(t),flag));
        }
    }
    //cout<<"ans= "<<ans<<endl;
    sort(ty.begin(),ty.end());
    //for(int i=0; i<ty.size();i++)cout<<ty[i]<<endl;
    ans=ty[0].first;
    /*
    if(ans+a<0)printf("%.f7",360+ans+a);
    else if(ans+a>360)printf("%.f7",ans+a-360);
    else printf("%.7f",ans+a);
    cout<<endl;
     */
    if(ty[0].second)printf("%.7f",ans+a);
    else printf("%.7f",a-ans);
    puts("");
    return 0;
    
}
accuracy: 0.04878048780487805
time_ms: 540
memory_kb: 3148
final_rank: 13

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
#include <assert.h>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 150005
#define EPS 0.000000001
using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    if(a==b)return puts("0")*0;
    double ans=INF;
    for(long long int i = -36000000;i<=36000000;++i){
        double t=i/100000.0;
        double v=(a+t);
        double w=(b-t);
        if(v>=360)v-=360;
        if(w>=360)w-=360;
        
        if(abs(v-w)<EPS &&abs(t)<ans){
            ans=t;
        }
    }
    if(ans+a<0)printf("%.f7",360+ans+a);
    else if(ans+a>360)printf("%.f7",ans+a-360);
    else printf("%.7f",ans+a);
    cout<<endl;
    return 0;
    
}
accuracy: 0.04878048780487805
time_ms: 250
memory_kb: 3156
final_rank: 9

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
#include <assert.h>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 150005
#define EPS 0.000000001
using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    double ans=INF;
    for(long long int i = -36000000;i<=36000000;++i){
        double t=i/100000.0;
        double v=(a+t);
        double w=(b-t);
        if(v>=360)v-=360;
        if(w>=360)w-=360;
        
        if(abs(v-w)<EPS &&abs(t)<ans){
            ans=t;
        }
    }
    if(ans+a<0)printf("%.f7",360+ans+a);
    else if(ans+a>360)printf("%.f7",ans+a-360);
    else printf("%.7f",ans+a);
    cout<<endl;
    return 0;
    
}
accuracy: 0.04878048780487805
time_ms: 250
memory_kb: 3228
final_rank: 15

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 150005
using namespace std;

int main(){
    double a,b;
    cin>>a>>b;
    double ans=INF;
    for(long double i = -36000000;i<=36000000;++i){
        double t=i/100000.0;
        double v=(a+t);
        double w=(b-t);
        if(v>=360)v-=360;
        if(w>=360)w-=360;
        
        if(v==w&&abs(t)<ans){
            ans=t;
        }
    }
    printf("%.7f",ans+a);
    cout<<endl;
    return 0;
    
}
accuracy: 0.04878048780487805
time_ms: 320
memory_kb: 3144
final_rank: 10

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -36000000;tt<=36000000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = fmod(a+t,360);
      else {
	if( LT(fabs(fmod(a+t,360)),fabs(ans)) ) { // t < ans
	  ans = fmod(a+t,360);
	}
      }
    }
  }
  printf("%.10f\n",ans);
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 780
memory_kb: 3180
final_rank: 17

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -36000000;tt<=36000000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = t;
      else {
	if( LT(fabs(t),fabs(ans)) ) { // t < ans
	  ans = t;
	}
      }
    }
  }
  printf("%.10f\n",fmod(a+ans,360));
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 790
memory_kb: 3268
final_rank: 19

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; } // a < b
bool LTE(double a,double b) { return equals(a,b) || a < b; } // a <= b

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -36000000;tt<=36000000;++tt ) {
    double t = tt/100000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = t;
      else {
	if( LT(fabs(t),fabs(ans)) ) { // t < ans
	  ans = t;
	}
      }
    }
  }
  printf("%.10f\n",a+ans);
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 780
memory_kb: 3272
final_rank: 20

code_snippet: #include<iostream>
#include<cmath>
#include<cstdio>
#include<cassert>

#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

int main() {
  double a,b;
  cin >> a >> b;
  double ans = -1;
  for(long long tt = -3600000;tt<=3600000;++tt ) {
    double t = tt/10000.0;
    double v = a + t;
    double w = b - t;
    if( LT(v,0) ) v += 360.0;
    v = fmod(v,360);
    w = fmod(w,360);
    if( equals(v,w) ) {
      if( equals(ans,-1) ) ans = t;
      else {
	if( LT(fabs(t),fabs(ans)) ) {
	  ans = t;
	}
      }
    }
  }
  printf("%.10f\n",a+ans);
  return 0;
}
accuracy: 0.04878048780487805
time_ms: 70
memory_kb: 3216
final_rank: 11