Educational Codeforces Round 87 (Rated for Div. 2)

A.

 

 

 

 

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d; 
        if(b >= a) {
            cout << b <<endl;
        }
        else if(c <= d) {
                cout << -1 <<endl;
        }
        else {
            ll s = (a - b) / (c - d);
            if(s * (c - d) < (a - b)) {
                s++;
            }
            cout << b + s * c << endl;
        }
    }
}

  B.贪心算法

 

 

 

 C.计算几何简单版

 

 

 

 

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        double ans = 1.0 / tan(acos(-1) / (n * 2));
        printf("%.9f\n", ans);
    }
}

  C2.计算几何(复杂版)

 

 

 

 

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        double ans = 1.0 / (2.0 * sin(acos(-1) / (4 * n)));
        printf("%.9f\n", ans);
    }
}

  

posted @ 2020-05-19 23:03  LightAc  阅读(180)  评论(0编辑  收藏  举报
返回顶端