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
  • 相关阅读:
    Object类学习
    Thread.State 线程状态
    Thread.UncaughtExceptionHandler
    apply和call的区别
    如何实现border-width:0.5px;
    table固定头部,表格tbody可上下左右滑动
    canvas画布实现手写签名效果
    ES6学习笔记
    for循环中执行setTimeout问题
    javaScript函数提升及作用域
  • 原文地址:https://www.cnblogs.com/demodemo/p/4748952.html
Copyright © 2011-2022 走看看