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
", 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
", ans);
    }
}

  

作者:LightAc
出处:https://www.cnblogs.com/lightac/
联系:
Email: dzz@stu.ouc.edu.cn
QQ: 1171613053
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/lightac/p/12920248.html