結果

問題 No.1236 長針と短針
ユーザー seiyuseiyu
提出日時 2020-09-27 01:19:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,578 bytes
コンパイル時間 1,786 ms
コンパイル使用メモリ 166,864 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 13:55:05
合計ジャッジ時間 2,665 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
static const double pi = 3.141592653589793;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}
int s_int(string s){
  return atoi(s.c_str());
}
int main(){
    string s, t;
    cin >> s >> t;
    double a, b;
    a = s_int(s);
    b = s_int(t);
    if(a > 12)
        a -= 12;
    double aa = 360.0 / 12 * a +360.0 / (12.0 * 60) * b;//長針
    double bb = 360.0 / 60 * b;//分針
    double cc = 360 *( 1 / (60.0 * 60) - 1 / (12.0 * 60 * 60)); // 1秒で縮まる角度
    // cout << aa << " " << bb << " " << cc << endl;
    if((aa == 0 || aa == 360) && (bb == 0 || bb == 360)){
        cout << 0 << endl;
    }
    else if(bb < aa){
        double sub = aa - bb;
        // cout << sub << endl;
        int ans = sub / cc;
        cout << ans << endl;
    }else{
        double sub = aa + 360 - bb;
        // cout << "Yes" << endl;
        // cout << sub << endl;
        int ans = sub / cc;
        cout << ans << endl;
    }
    return 0;
}
0