zoukankan      html  css  js  c++  java
  • Gym 100952 B. New Job

    B. New Job
    time limit per test
    1 second
    memory limit per test
    64 megabytes
    input
    standard input
    output
    standard output

    This is the first day for you at your new job and your boss asks you to copy some files from one computer to other computers in an informatics laboratory. He wants you to finish this task as fast as possible. You can copy the files from one computer to another using only one Ethernet cable. Bear in mind that any File-copying process takes one hour, and you can do more than one copying process at a time as long as you have enough cables. But you can connect any computer to one computer only at the same time. At the beginning, the files are on one computer (other than the computers you want to copy them to) and you want to copy files to all computers using a limited number of cables.

    Input

    First line of the input file contains an integer T (1  ≤  T  ≤  100) which denotes number of test cases. Each line in the next T lines represents one test case and contains two integers N, M.

    N is the number of computers you want to copy files to them (1  ≤  N  ≤  1,000,000,000). While M is the number of cables you can use in the copying process (1  ≤  M  ≤  1,000,000,000).

    Output

    For each test case, print one line contains one integer referring to the minimum hours you need to finish copying process to all computers.

    Examples
    Input
    3
    10 10
    7 2
    5 3
    Output
    4
    4
    3
    一台电脑只能与另一台电脑连接,所以t*=2,当电线用完后,将以链接的电脑减去,不带复制m即可
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <queue>
    #include <cmath>
    #include <map>
    #include <vector>
    #include <algorithm>
    using namespace std;
    #define lowbit(x) (x&(-x))
    #define max(x,y) (x>y?x:y)
    #define min(x,y) (x<y?x:y)
    #define MAX 100000000000000000
    #define MOD 1000000007
    #define PI 3.141592653589793238462
    #define INF 0x3f3f3f3f3f
    #define mem(a) (memset(a,0,sizeof(a)))
    typedef long long ll;
    int dp[1260];
    int a[15],t;
    int main()
    {
        ll t,n,m;
        scanf("%lld",&t);
        while(t--)
        {
            scanf("%lld%lld",&n,&m);
            n;
            ll pos=0;
            ll ans=0;
            ll cnt=1;
            for(ll i=1;;i++)
            {
                if(m<=cnt)
                {
                    cnt=m;
                    ans++;
                    pos+=cnt;
                    if(pos>=n)
                    {
                        cout<<ans<<endl;
                        break;
                    }
                    if((n-pos)%cnt==0) ans+=(n-pos)/cnt;
                    else ans+=(n-pos)/cnt+1;
                    cout<<ans<<endl;
                    break;
                }
                ans++;
                pos+=cnt;
                if(pos>=n)
                {
                    cout<<ans<<endl;
                    break;
                }
                cnt*=2;
            }
        }
        return 0;
    }
  • 相关阅读:
    搜索优化
    ETL(Extract-Transform-Load的缩写,即数据抽取、转换、装载的过程)
    Tomcat7.0.22在Windows下详细配置过程
    maven 安装配置
    Venus wiki
    搜索引擎基本原理及实现技术——用户查询意图分析
    sql 表自连接
    select 多表查询
    select 嵌套
    Ioc和Aop扩展--多种方式实现依赖注入(构造注入,p命名空间注入,集合类型注入,注入null和注入空值)
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7199113.html
Copyright © 2011-2022 走看看