A.HDU6276:Easy h-index

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1181    Accepted Submission(s): 415

Problem Description
比赛题目:
http://acm.hdu.edu.cn/downloads/2018ccpc_hn.pdf

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 published many papers.
Given a0,a1,a2,…,an which means Bobo has published ai papers with citations exactly i, find the h-index of Bobo.

 
Input
The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains an integer n.
The second line contains (n+1) integers a0,a1,…,an.

 
Output
For each test case, print an integer which denotes the result.

## Constraint

* 1≤n≤2⋅105
* 0≤ai≤109
* The sum of n does not exceed 250,000.

 
Sample Input
1
1 2
2
1 2 3
3
0 0 0 0
 
Sample Output
1
2
0
 
 
题意:
  题意看了很久看晕了...
  题目意思是:从 a到 a给 n+1 个数,每个数 a表示被引用次数等于 i 的文章数量。现在要在0~n 中找到满足 被引用次数大于等于h的论文至少有h张中最大的h。
题解:
  从后往前遍历,计算后缀和,当和大于当前下标时直接输出就行了。
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
const int N = 2e5 +;
const int INF = 2e9+;
const int mod = 1e9+;
ll a[N];
int main() {
int n;
while (~scanf("%d",&n)){
for (int i = ; i <= n; i++) {
scanf("%lld",&a[i]);
}
ll ans = ;
for (int i =n; i >= ; i--){
ans += a[i];
if (ans >= i){
printf("%d\n",i);
break ;
}
}
}
return ;
}

F.HDU6281:Sorting

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1482    Accepted Submission(s): 407

Problem Description
Bobo has n tuples (a1,b1,c1),(a2,b2,c2),…,(an,bn,cn).
He would like to find the lexicographically smallest permutation p1,p2,…,pn of 1,2,…,n such that for i∈{2,3,…,n} it holds that

 
Input
The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains an integer n.
The i-th of the following n lines contains 3 integers ai, bi and ci.

 
Output
For each test case, print n integers p1,p2,…,pn seperated by spaces.
DO NOT print trailing spaces.

## Constraint

* 1≤n≤103
* 1≤ai,bi,ci≤2×109
* The sum of n does not exceed 104.

 
Sample Input
2
1 1 1
1 1 2
2
1 1 2
1 1 1
3
1 3 1
2 2 1
3 1 1
 
Sample Output
2 1
1 2
1 2 3
 
 
题意:
   给你n个元组要你按要求排序。
 
题解:
  直接sort就行了。不过要注意:
  1.在按这个公式比较时最好不要用除法(可能会丢失精度)。
  2.用乘法是可能会爆unsigned long long,所以我们要先进行约分再来比较。

#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
const int N = 1e3 +;
const int INF = 2e9+;
const int mod = 1e9+;
struct node{
int id;
ll a,b,c;
}p[N];
bool cmp(node x,node y){
ll ans1 = (x.a+x.b)*y.c;
ll ans2 = (y.a+y.b)*x.c;
if (ans1 == ans2){
return x.id<y.id;
}
return ans1 < ans2;
}
int main() {
int n;
while (~scanf("%d",&n)){
for (int i = ; i < n; i++) {
p[i].id = i + ;
scanf("%lld%lld%lld",&p[i].a,&p[i].b,&p[i].c);
}
sort(p,p+n,cmp);
for (int i = ; i < n-; i++){
printf("%d ",p[i].id);
}
printf("%d\n",p[n-].id);
}
return ;
}
 

K.HDU6286:

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 908    Accepted Submission(s): 457

Problem Description
Given a,b,c,d, find out the number of pairs of integers (x,y) where a≤x≤b,c≤y≤d and x⋅y is a multiple of 2018.
 
Input
The input consists of several test cases and is terminated by end-of-file.

Each test case contains four integers a,b,c,d.

 
Output
For each test case, print an integer which denotes the result.

## Constraint

* 1≤a≤b≤109,1≤c≤d≤109
* The number of tests cases does not exceed 104.

 
Sample Input
1 2 1 2018
1 2018 1 2018
1 1000000000 1 1000000000
 
Sample Output
3
6051
1485883320325200
 
 
题意:
   问有多少对有序数组(x,y)(x∈[a,b],y∈[c,d])使得x*y是2018的倍数
 
 
题解:
  我们可以分类讨论,将[a,b]区间的数分为4种:
  1.x1:2018的倍数,此时x1中的数与[c,d]区间的任意一个数相乘都能组成2018的倍数。  
    ans += x1 * [c,d]中数个数
  2.x2:除x1以外的偶数(因为x1已经计算过了,不减去会重复计算),此时x2中的数与[c,d]中1009的倍数相乘都能组成2018的倍数。
    ans += x2 * [c,d]中1009的倍数的个数
  3.x3:1009的奇数倍(偶数倍为2018的倍数,已经计算过),此时x3中的数与[c,d]中的偶数相乘都能组成2018的倍数。
    ans += x3 * [c,d]中偶数的个数
  4.x4:除1009倍数以外的奇数,此时x4中的数与[c,d]中偶数相乘都能组成2018的倍数。
    ans += x4 * [c,d]中2018的倍数的个数

#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define ull unsigned ll
#define exp 1e-8
using namespace std;
const int N = 1e3 +;
const int INF = 2e9+;
const int mod = 1e9+;
int main() {
ll a,b,c,d;
while (cin>>a>>b>>c>>d){
ll ans = ;
ll x1 =b/ - (a-)/; //a~b中2018的倍数 × all
ans += x1 * (d-c+);
ll x2 = b/-(a-)/ - x1; //a~b中偶数(除了x1)的个数 × 1009倍数
ans += x2 * (d/ - (c-)/);
ll x3 = b/ - (a-)/ - x1;//a~b中1009的奇数倍 × 偶数
ans += x3 * (d/ - (c-)/);
ll x4 = (b-a+) - (b/-(a-)/) - x3;//a~b中奇数的个数 × 2018倍数
ans += x4 * (d/ - (c-)/);
//printf("%lld %lld %lld %lld \n",x1,x2,x3,x4);
cout << ans << '\n';
}
return ;
}
 
 
 
 
 
 
 
 
 

2018湘潭邀请赛 AFK题解 其他待补...的更多相关文章

  1. 2018湘潭邀请赛C题(主席树+二分)

    题目地址:https://www.icpc.camp/contests/6CP5W4knRaIRgU 比赛的时候知道这题是用主席树+二分,可是当时没有学主席树,就连有模板都不敢套,因为代码实在是太长了 ...

  2. 湘潭邀请赛+蓝桥国赛总结暨ACM退役总结

    湘潭邀请赛已经过去三个星期,蓝桥也在上个星期结束,今天也是时候写一下总结了,这应该也是我的退役总结了~ --------------------------------湘潭邀请赛----------- ...

  3. XTU 1264 - Partial Sum - [2017湘潭邀请赛E题(江苏省赛)]

    2017江苏省赛的E题,当时在场上看错了题目没做出来,现在补一下…… 题目链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id ...

  4. 2018宁夏邀请赛 L Continuous Intervals(单调栈+线段树)

    2018宁夏邀请赛 L Continuous Intervals(单调栈+线段树) 传送门:https://nanti.jisuanke.com/t/41296 题意: 给一个数列A 问在数列A中有多 ...

  5. 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)

    湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...

  6. 湘潭邀请赛 Hamiltonian Path

    湘潭邀请赛的C题,哈密顿路径,边为有向且给定的所有边起点小于终点,怎么感觉是脑筋急转弯? 以后一定要牢记思维活跃一点,把复杂的事情尽量简单化而不是简单的事情复杂化. #include<cstdi ...

  7. 湘潭邀请赛 2018 I Longest Increasing Subsequence

    题意: 给出一个长度为n的序列,序列中包含0.定义f(i)为把所有0变成i之后的Lis长度,求∑ni=1i⋅f(i). 题解: 设不考虑0的Lis长度为L,那么对于每个f(i),值为L或L+1. 预处 ...

  8. 湘潭邀请赛 2018 E From Tree to Graph

    题意: 给出一棵树以及m,a,b,x0,y0.之后加m条边{(x1,LCA(x1,y1)),(x2,LCA(x2,y2))...(xm,LCA(xm,ym))}.定义z = f(0)^f(1)^... ...

  9. 湘潭邀请赛 2018 D Circular Coloring

    题意: 给一个环,环上有n+m个点.给n个点染成B,m个点染成W.求所有染色情况的每段长度乘积之和. 题解: 染成B的段数和染成W的段数是一样的(因为是环). 第一段是可以移动的,例如BBWWW移动为 ...

随机推荐

  1. oracle用NOT EXISTS替代NOT IN

    在子查询中,NOT IN子句将执行一个内部的排序和合并. 无论在哪种情况下,NOT IN都是最低效的 (因为它对子查询中的表执行了一个全表遍历).  为了避免使用NOT IN ,我们可以把它改写成外连 ...

  2. SQLSTATE[HY000] [2002] 错误

    http://www.thinkphp.cn/topic/36194.html 使用tp框架 3.2.3 ,在windows上跑的时候没有任何问题,但是部署到linux系统和是哪个,就会报这个错,不知 ...

  3. hdu 1255 覆盖的面积 (Bruceforce)

    Problem - 1255 暴力统计覆盖超过一次的区域.1y. 代码如下: #include <cstdio> #include <cstring> #include < ...

  4. 手机QQ浏览器属于代理服务器吗?

    这两天.上QQ,会员上线提示.老是显示福建省,而没有具体的地方.这是怎么回事呢?而且那个时间段我都没有上QQ.但是有用手机QQ浏览器.偷菜.这是怎么回事,机子也没有病毒 没有木马 到底怎么搞的...! ...

  5. 【原生JS】动态分页样式效果

    效果图如下: html: <body> <div> <table id="btnbox"> <tbody> <tr>&l ...

  6. Reasoning and Learing学习笔记

    Assignment 1 question 1 1.clisp安装及运行->参考博客 2.参数为列表,参考PPT 3.把嵌套列表变成非嵌套->题目P07 代码

  7. [转]C# 语言历史版本特性(C# 1.0到C# 8.0汇总)

    历史版本 C#作为微软2000年以后.NET平台开发的当家语言,发展至今具有17年的历史,语言本身具有丰富的特性,微软对其更新支持也十分支持.微软将C#提交给标准组织ECMA,C# 5.0目前是ECM ...

  8. 深入java面向对象三:抽象类和接口(转载)

    文章系转载,地址: http://blog.csdn.net/xw13106209/article/details/6923556 1.概述     一个软件设计的好坏,我想很大程度上取决于它的整体架 ...

  9. 2018-2-13-C#-枚举转字符串

    title author date CreateTime categories C# 枚举转字符串 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:23:3 ...

  10. 通过页码直接跳转 html

    <?php namespace Admin\TagLib; class BootstrapPage{ public $firstRow; // 起始行数 public $listRows; // ...