• Codeforces Round #421 (Div. 2)


    所幸昨晚出锅了,unrated

    A. Mister B and Book Reading
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had c pages.

    At first day Mister B read v0 pages, but after that he started to speed up. Every day, starting from the second, he read a pages more than on the previous day (at first day he read v0 pages, at second — v0 + a pages, at third — v0 + 2a pages, and so on). But Mister B is just a human, so he physically wasn't able to read more than v1 pages per day.

    Also, to refresh his memory, every day, starting from the second, Mister B had to reread last l pages he read on the previous day. Mister B finished the book when he read the last page for the first time.

    Help Mister B to calculate how many days he needed to finish the book.

    Input

    First and only line contains five space-separated integers: cv0, v1, a and l (1 ≤ c ≤ 1000, 0 ≤ l < v0 ≤ v1 ≤ 1000, 0 ≤ a ≤ 1000) — the length of the book in pages, the initial reading speed, the maximum reading speed, the acceleration in reading speed and the number of pages for rereading.

    Output

    Print one integer — the number of days Mister B needed to finish the book.

    Examples
    input
    5 5 10 5 4
    output
    1
    input
    12 4 12 4 1
    output
    3
    input
    15 1 100 0 0
    output
    15
    Note

    In the first sample test the book contains 5 pages, so Mister B read it right at the first day.

    In the second sample test at first day Mister B read pages number 1 - 4, at second day — 4 - 11, at third day — 11 - 12 and finished the book.

    In third sample test every day Mister B read 1 page of the book, so he finished in 15 days.

    A题简单模拟。你有c页书,每天读v0+at页,最多读v1页,忘记l页,问多少天读完

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    int main(){
        int c,v0,v1,a,l;
        cin>>c>>v0>>v1>>a>>l;
        int f=1;
        for(;;f++){
            c-=v0;
            v0+=a;
            if(v0>v1)
            v0=v1;
            if(c<=0)
            return 0*printf("%d",f);
            c+=l;
        }
    }
    B. Mister B and Angle in Polygon
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).

    That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle  (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value  should be minimum possible.

    If there are many optimal solutions, Mister B should be satisfied with any of them.

    Input

    First and only line contains two space-separated integers n and a (3 ≤ n ≤ 105, 1 ≤ a ≤ 180) — the number of vertices in the polygon and the needed angle, in degrees.

    Output

    Print three space-separated integers: the vertices v1, v2, v3, which form . If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.

    Examples
    input
    3 15
    output
    1 2 3
    input
    4 67
    output
    2 1 3
    input
    4 68
    output
    4 1 2
    Note

    In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.

    Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".

    In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".

     B题是个几何,就是n边形n个点选三个点构成的角度最接近某个角度a,利用n边形性质暴力枚举,本来写错了一直wa,最后都没改对

    #include <stdio.h>
    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        int a,v,f;
        cin>>a>>v;
        double ma=1<<30;
        for(int i=1; i<a-1; i++){
            if(fabs(i*180.0/a-v)<fabs(ma-v)) {
                ma=i*180.0/a;
                f=i;
            }
        }
        cout<<1<<" "<<2<<" "<<a-f+1;
        return 0;
    }
  • 相关阅读:
    [Swift通天遁地]五、高级扩展-(2)扩展集合类型
    [Swift通天遁地]五、高级扩展-(1)快速检测设备属性:版本、类型、屏幕尺寸
    [Swift]LeetCode266.回文全排列 $ Palindrome Permutation
    [Swift]LeetCode265.粉刷房子 II $ Paint House II
    [Swift]LeetCode264.丑数 II | Ugly Number II
    [Swift通天遁地]四、网络和线程-(15)程序内购功能
    [Swift通天遁地]四、网络和线程-(14)创建一个Socket服务端
    hdu 4888 Redraw Beautiful Drawings(最大流,判环)
    【剑指offer】斐波那契序列与跳台阶
    Asp.NET之对象学习
  • 原文地址:https://www.cnblogs.com/BobHuang/p/7089471.html
Copyright © 2020-2023  润新知