library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub beet-aizu/library

:heavy_check_mark: test/yukicoder/4941.test.cpp

Depends on

Code

// verification-helper: PROBLEM https://yukicoder.me/problems/4941

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#include "../../math/fraction.cpp"
#undef call_from_test

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s,t;
  cin>>s>>t;
  int a=(s[0]-'0')*10+(s[1]-'0');
  int b=(t[0]-'0')*10+(t[1]-'0');

  using F = fraction<int>;
  F c(a*60+b,1);
  F d(720,11);
  F x(0,1);
  while(x<c) x=x+d;
  x=x-c;
  cout<<x.num*60/x.den<<endl;
  return 0;
}
#line 1 "test/yukicoder/4941.test.cpp"
// verification-helper: PROBLEM https://yukicoder.me/problems/4941

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#line 1 "math/fraction.cpp"

#line 3 "math/fraction.cpp"
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T>
struct fraction{
  T num,den;
  fraction(T n,T d):num(n),den(d){
    assert(den!=0);
    if(den<0) num*=-1,den*=-1;
    T tmp=gcd(abs(num),abs(den));
    num/=tmp;
    den/=tmp;
  }
  const fraction operator+(const fraction& a) const{
    return fraction(num*a.den+a.num*den,den*a.den);
  }
  const fraction operator-(const fraction& a) const{
    return fraction(num*a.den-a.num*den,den*a.den);
  }
  const fraction operator*(const fraction& a) const{
    return fraction(num*a.num,den*a.den);
  }
  const fraction operator/(const fraction& a) const{
    return fraction(num*a.den,den*a.num);
  }
  const fraction operator*(T k) const{return fraction(num*k,den);}
  const fraction operator/(T k) const{return fraction(num,den*k);}
#define define_cmp(op) \
  bool operator op (const fraction& a) const{return num*a.den op a.num*den;}
  define_cmp(==)
  define_cmp(!=)
  define_cmp(<)
  define_cmp(>)
  define_cmp(<=)
  define_cmp(>=)
#undef define_cmp
};
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed main(){
  return 0;
}
#endif
#line 8 "test/yukicoder/4941.test.cpp"
#undef call_from_test

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s,t;
  cin>>s>>t;
  int a=(s[0]-'0')*10+(s[1]-'0');
  int b=(t[0]-'0')*10+(t[1]-'0');

  using F = fraction<int>;
  F c(a*60+b,1);
  F d(720,11);
  F x(0,1);
  while(x<c) x=x+d;
  x=x-c;
  cout<<x.num*60/x.den<<endl;
  return 0;
}
Back to top page