結果

問題 No.2776 Bigger image
ユーザー t98slidert98slider
提出日時 2024-06-07 21:33:48
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,078 bytes
コンパイル時間 2,747 ms
コンパイル使用メモリ 200,440 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 07:14:27
合計ジャッジ時間 3,182 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> istream& operator >> (istream& is, vector<T>& vec) {
for(T& x : vec) is >> x;
return is;
}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
if(vec.empty()) return os;
os << vec[0];
for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
return os;
}
struct yuri {
ll num,den;
yuri() : num(0),den(1) {}
yuri(ll a) : num(a),den(1){}
yuri(ll a,ll b) : num(a),den(b){safe();}
void safe(){
if(den<0)den*=-1,num*=-1;
ll v=__gcd(abs(num),den);
num/=v,den/=v;
}
yuri& operator++() {num+=den;return *this;}
yuri& operator--() {num-=den;return *this;}
yuri& operator+=(const yuri& rhs) {
num=num*rhs.den+den*rhs.num;
den=den*rhs.den;
safe();
return *this;
}
yuri& operator-=(const yuri& rhs) {
num=num*rhs.den-den*rhs.num;
den=den*rhs.den;
safe();
return *this;
}
yuri& operator*=(const yuri& rhs) {
num=num*rhs.num;
den=den*rhs.den;
safe();
return *this;
}
yuri& operator/=(const yuri& rhs) {
num=num*rhs.den;
den=den*rhs.num;
safe();
return *this ;
}
yuri operator+() const { return *this; }
yuri operator-() const { return yuri() - *this; }
friend yuri operator+(const yuri& lhs, const yuri& rhs) {
return yuri(lhs) += rhs;
}
friend yuri operator-(const yuri& lhs, const yuri& rhs) {
return yuri(lhs) -= rhs;
}
friend yuri operator*(const yuri& lhs, const yuri& rhs) {
return yuri(lhs) *= rhs;
}
friend yuri operator/(const yuri& lhs, const yuri& rhs) {
return yuri(lhs) /= rhs;
}
friend bool operator==(const yuri& lhs, const yuri& rhs) {
return (lhs.num==rhs.num&&lhs.den==rhs.den);
}
friend bool operator!=(const yuri& lhs, const yuri& rhs) {
return (lhs.num!=rhs.num||lhs.den!=rhs.den);
}
friend bool operator<(const yuri& lhs, const yuri& rhs) {
return (lhs.num*rhs.den<lhs.den*rhs.num);
}
friend bool operator<=(const yuri& lhs, const yuri& rhs) {
return (lhs.num*rhs.den<=lhs.den*rhs.num);
}
friend bool operator>(const yuri& lhs, const yuri& rhs) {
return (lhs.num*rhs.den>lhs.den*rhs.num);
}
friend bool operator>=(const yuri& lhs, const yuri& rhs) {
return (lhs.num*rhs.den>=lhs.den*rhs.num);
}
friend ostream& operator << (ostream &os, const yuri& rhs) noexcept {
if(rhs.den==1)return os << rhs.num;
return os << rhs.num << '/' << rhs.den;
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll a, b, h, w;
cin >> a >> b >> h >> w;
yuri f1 = min(yuri(h, a), yuri(w, b));
yuri f2 = min(yuri(h, b), yuri(w, a));
if(f1 == f2){
cout << "Same" << '\n';
return 0;
}
if(f1 > f2){
cout << "Non-rotating\n";
}else{
cout << "Rotating\n";
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0