zoukankan      html  css  js  c++  java
  • music

    n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.

    Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could have formed by the end of the competition.

    Input

    The only line of input contains two integers n and m, separated by a single space (1 ≤ m ≤ n ≤ 109) — the number of participants and the number of teams respectively.

    Output

    The only line of the output should contain two integers kmin and kmax — the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.

    Sample test(s)
    input
    5 1
    output
    10 10
    input
    3 2
    output
    1 1
    input
    6 3
    output
    3 6
    Note

    In the first sample all the participants get into one team, so there will be exactly ten pairs of friends.

    In the second sample at any possible arrangement one team will always have two participants and the other team will always have one participant. Thus, the number of pairs of friends will always be equal to one.

    In the third sample minimum number of newly formed friendships can be achieved if participants were split on teams consisting of 2people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people.

    题意:一首歌会播放T秒,在第一次播放之前先缓冲s秒,播放后每q秒就会缓冲q-1秒的音乐,如果音乐播放到某一个地方但是还没有缓冲到,音乐就会重新开始播放,现在问音乐播放完毕时音乐重新播放了几次

    其实就是一个模拟题,,,,

    好水。。我一开始看不懂题目,,

    好难过。。

    #include<iostream>
    using namespace std;
    int main(){
        long long int t,s,q;
        while(cin>>t>>s>>q){
           long long  int ans=1;
         long long   int s2=0;
            while(s<t){
                if(s<=s2){
                    ans++;
                    s2=0;
                }
                s+=(q-1);
                s2+=q;
            }
            cout<<ans<<endl;
        }
    return 0;
    }
    View Code
  • 相关阅读:
    c++基类和派生类的框架
    从文件读入7个数并排序
    字符串复制函数-简单
    c++函数模板-简单
    用初始化列表解决常私有变量问题-简单
    分配和释放内存-简单
    结构体小程序-简单
    转化的力量
    初次创业需要注意的几点
    重生的2014下半年的起点
  • 原文地址:https://www.cnblogs.com/demodemo/p/4748952.html
Copyright © 2011-2022 走看看