列表

详情


NC52892. Higher h-index

描述

The h-index of an author is the largest h where he has at least h papers with citations not less than h.
Bobo has no papers and he is going to publish some subsequently.
If he works on a paper for x hours, the paper will get citations, where a is a known constant.
It's clear that x should be a positive integer.
There is also a trick -- one can cite his own papers published earlier.
Given Bobo has n working hours, find the maximum h-index of him.

输入描述

The input consists of several test cases and is terminated by end-of-file.
Each test case contains two integers n and a.


* The number of test cases does not exceed .

输出描述

For each test case, print an integer which denotes the maximum h-index.

示例1

输入:

3 0
3 1
1000000000 1000000000

输出:

1
2
1000000000

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C(clang 3.9) 解法, 执行用时: 6ms, 内存消耗: 376K, 提交时间: 2020-01-31 17:09:07

#include <stdio.h>
int main(){
   int n,a;
   while(scanf("%d%d",&n,&a)!=EOF){
    printf("%d\n",a+(n-a)/2);
   }
   return 0;
}

C++11(clang++ 3.9) 解法, 执行用时: 8ms, 内存消耗: 380K, 提交时间: 2020-02-25 20:58:14

#include<stdio.h>
int main()
{
	int x,a;
	while(scanf("%d %d\n",&x,&a)!=EOF)
	{
		printf("%d\n",(a+x)/2);
	}
}

Python3(3.5.2) 解法, 执行用时: 94ms, 内存消耗: 3552K, 提交时间: 2019-10-02 12:50:49

while True:
    try:
        n,m=map(int,input().split())
        print((n+m)//2)
    except:
        break

C++14(g++5.4) 解法, 执行用时: 24ms, 内存消耗: 340K, 提交时间: 2019-10-02 13:44:30

#include<bits/stdc++.h>
int main(){int n,a;while(std::cin>>n>>a)printf("%d\n",a+(n-a)/2);}

上一题