zoukankan      html  css  js  c++  java
  • Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)

    这场比赛很惨啊

    A. k-rounding
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10and is divisible by n.

    For example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such that it ends with 4 or more zeros and is divisible by 375.

    Write a program that will perform the k-rounding of n.

    Input

    The only line contains two integers n and k (1 ≤ n ≤ 109, 0 ≤ k ≤ 8).

    Output

    Print the k-rounding of n.

    Examples
    input
    375 4
    output
    30000
    input
    10000 1
    output
    10000
    input
    38101 0
    output
    38101
    input
    123456789 8
    output
    12345678900000000

     A就是个简单的模拟啦,直接瞎搞

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main()
    {
        ll n;
        int k;
        ll a,b,c;
        cin>>n>>k;
        if(k==0)cout<<n<<endl;
        else
        {
            a=1;
            while(k--)
            {
                a*=10;
            }
            b=a%n;
            c=__gcd(b,n);
            c=n/c;
            cout<<c*a<<endl;
        }
        return 0;
    }
    B. Which floor?
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the next several flats are on the second and so on. Polycarp don't remember the total number of flats in the building, so you can consider the building to be infinitely high (i.e. there are infinitely many floors). Note that the floors are numbered from 1.

    Polycarp remembers on which floors several flats are located. It is guaranteed that this information is not self-contradictory. It means that there exists a building with equal number of flats on each floor so that the flats from Polycarp's memory have the floors Polycarp remembers.

    Given this information, is it possible to restore the exact floor for flat n?

    Input

    The first line contains two integers n and m (1 ≤ n ≤ 100, 0 ≤ m ≤ 100), where n is the number of the flat you need to restore floor for, and m is the number of flats in Polycarp's memory.

    m lines follow, describing the Polycarp's memory: each of these lines contains a pair of integers ki, fi(1 ≤ ki ≤ 100, 1 ≤ fi ≤ 100), which means that the flat ki is on the fi-th floor. All values ki are distinct.

    It is guaranteed that the given information is not self-contradictory.

    Output

    Print the number of the floor in which the n-th flat is located, if it is possible to determine it in a unique way. Print -1 if it is not possible to uniquely restore this floor.

    Examples
    input
    10 3
    6 2
    2 1
    7 3
    output
    4
    input
    8 4
    3 1
    6 2
    5 2
    2 1
    output
    -1
    Note

    In the first example the 6-th flat is on the 2-nd floor, while the 7-th flat is on the 3-rd, so, the 6-th flat is the last on its floor and there are 3 flats on each floor. Thus, the 10-th flat is on the 4-th floor.

    In the second example there can be 3 or 4 flats on each floor, so we can't restore the floor for the 8-th flat.

    这个题还是挺难的啊,什么破题都是,得大力模拟,情况真多啊,心累,这场fst很多人,都不rated了。奇坑场

    #include <bits/stdc++.h>
    using namespace std;
    int n,m,ma=1,mi=100;
    int main()
    {
        scanf("%d%d",&n,&m);
        for(int i=1; i<=m; i++)
        {
            int a,f;
            scanf("%d%d",&a,&f);
            if(a==n)
            {
                printf("%d",f);
                return 0;
            }
            int p=a/f,p1=f==1?mi:(a-1)/(f-1);
            if(a%f)p++;
            ma=max(ma,p);
            mi=min(mi,p1);
        }
        if(ma<=mi)
        {
            int c=n/ma;
            if(n%ma)c++;
            int cc=n/mi;
            if(n%mi)cc++;
            if(c==cc)printf("%d",c);
            else printf("-1");
        }
        else printf("-1");
        return 0;
    }
  • 相关阅读:
    day04用户交互和运算符
    day04垃圾回收机制
    day4
    B2. K for the Price of One (Hard Version)
    C. New Year and Permutation
    Rational Ratio
    C. Two Arrays
    D. MEX maximizing
    B. Infinite Prefixes
    C. Obtain The String
  • 原文地址:https://www.cnblogs.com/BobHuang/p/7554855.html
Copyright © 2011-2022 走看看