2017 Multi-University Training Contest - Team 6—HDU6098&&HDU6106&&HDU6103
HDU6098 Inversion
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6098
题目意思:题目很短,给出一个数组,下标从1开始,现在输出一个数组,下标为j的数为表示原来的数组中下标j%i(当前数组中的下标)!=0中最大的数。
思路:很简单,将原来的一个数组的值带下标组成一个结构体,按照值得大小从大到小排序,然后对于每次询问从头扫第一个符合j%i!=0的值就是答案。
代码:
- //Author: xiaowuga
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <queue>
- #include <cmath>
- #include <cstring>
- #include <cstdio>
- #include <ctime>
- #include <map>
- #include <bitset>
- #include <cctype>
- #define maxx INT_MAX
- #define minn INT_MIN
- #define inf 0x3f3f3f3f
- #define mem(s,ch) memset(s,ch,sizeof(s))
- #define nc cout<<"nc"<<endl
- #define sp " "
- const long long N=+;
- using namespace std;
- typedef long long LL;
- typedef int II;
- struct node{
- LL val,pos;
- bool operator <(const node& m) const{
- return val>m.val;
- }
- }a[N];
- II n;
- int main() {
- ios::sync_with_stdio(false);cin.tie();
- II T;
- cin>>T;
- while(T--){
- cin>>n;
- for(II i=;i<=n;i++){
- cin>>a[i].val;
- a[i].pos=i;
- }
- sort(a+,a+n+);
- II flag=;
- for(II i=;i<=n;i++){
- for(II j=;j<=n;j++){
- if(a[j].pos%i!=){
- if(flag) {cout<<a[j].val;flag=;}
- else cout<<sp<<a[j].val;
- break;
- }
- }
- }
- cout<<endl;
- }
- return ;
- }
HDU6106 Classes
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6106
题目意思:有n个班级,给出一个班选a课程,选b课程,选c课程的,选ab课程的,选ac课程的,选bc课程的人数。有的班数据可能有错(比如给出的数据导致选某个课的人数为负数),我们直接忽略。找出班级人数最大的班级,并输出人数。
思路:这里说明一下带有o前缀代表只选了选某个课程的人数,我们可以画一个ven图。发现存在以下关系
oab=ab-abc; oa=a-ab-ac+abc;
oac=ac-abc; ob=b-ab-bc+abc;
obc=bc-abc; oc=c-ac-bc+abc;
以上所有的算出来否不能为负数才是合法的数据,否则忽略直接计算下一组数据。
如果是合法,oa+ob+oc+oab+obc+oac+abc就是这个班的人数,在数据是合法的班里面找出人数最多的班输出他们的人数。
代码:
- //Author: xiaowuga
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <queue>
- #include <cmath>
- #include <cstring>
- #include <cstdio>
- #include <ctime>
- #include <map>
- #include <bitset>
- #include <cctype>
- #define maxx INT_MAX
- #define minn INT_MIN
- #define inf 0x3f3f3f3f
- #define mem(s,ch) memset(s,ch,sizeof(s))
- #define nc cout<<"nc"<<endl
- #define sp " "
- const long long N=;
- using namespace std;
- typedef long long LL;
- typedef int II;
- II n,a,b,c,ab,ac,bc,abc;
- int main() {
- ios::sync_with_stdio(false);cin.tie();
- II T;
- cin>>T;
- while(T--){
- II ans=;
- cin>>n;
- for(II i=;i<n;i++){
- cin>>a>>b>>c>>ab>>bc>>ac>>abc;
- II oab=ab-abc;
- II oac=ac-abc;
- II obc=bc-abc;
- if(oab<||obc<||oac<) continue;
- II oa=a-ab-ac+abc;
- II ob=b-ab-bc+abc;
- II oc=c-ac-bc+abc;
- if(oa<||ob<||oc<) continue;
- ans=max(ans,oa+ob+oc+oab+obc+oac+abc);
- }
- cout<<ans<<endl;
- }
- return ;
- }
HDU6103 Kirinriki
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6103
题目意思:在一个字符串S里面找出两个不重叠且长度相等的长度为n的子串,使得两个子串的dist不大于m,问n的最大值是多少?
思路:比赛的时候智障,没想到枚举中心,尽然没有写出来,这里说下为什么枚举中心。因为作为答案两个字符串一定关于某一个中心对称。我们以某个中心,从两边两个指针,往里面缩进,从而找到dist最近m的边界值。然后头尾指针缩进一格,减去头尾指针的贡献。然后继续直到下一次接近m的边界值。过程中记录长度的最大值。这里注意奇数中心和偶数中心的问题,我因此wa了一发。orz
代码:
- //Author: xiaowuga
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <queue>
- #include <cmath>
- #include <cstring>
- #include <cstdio>
- #include <ctime>
- #include <map>
- #include <bitset>
- #include <cctype>
- #define maxx INT_MAX
- #define minn INT_MIN
- #define inf 0x3f3f3f3f
- #define mem(s,ch) memset(s,ch,sizeof(s))
- #define nc cout<<"nc"<<endl
- #define sp " "
- const long long N=;
- using namespace std;
- typedef long long LL;
- typedef int II;
- char q[N];
- int main() {
- II T;
- scanf("%d",&T);
- II ct,sum;
- while(T--){
- II m;
- scanf("%d",&m);
- getchar();
- scanf("%s",q);
- II ans=,ct,sum;
- II len=strlen(q);
- for(II i=;i<len-;i++){
- II lim=min(i+,len-i-);
- II l=i-lim+,r=i+lim;
- II x=l,y=r;
- sum=ct=;
- for(II k=;k<lim;){
- II t=abs(q[x+k]-q[y-k]);
- if(sum+t<=m){
- sum+=t;
- ct++;
- ans=max(ans,ct);
- k++;
- }
- else{
- sum-=abs(q[l]-q[r]);
- l++;r--;
- ct--;
- }
- }
- lim=min(i,len-i-);
- x=l=i-lim;y=r=i+lim;
- sum=ct=;
- for(II k=;k<lim;){
- II t=abs(q[x+k]-q[y-k]);
- if(sum+t<=m){
- sum+=t;
- ct++;
- ans=max(ans,ct);
- k++;
- }
- else{
- sum-=abs(q[l]-q[r]);
- l++;r--;
- ct--;
- }
- }
- }
- cout<<ans<<endl;
- }
- return ;
- }
2017 Multi-University Training Contest - Team 6—HDU6098&&HDU6106&&HDU6103的更多相关文章
- 2017 Multi-University Training Contest - Team 9 1005&&HDU 6165 FFF at Valentine【强联通缩点+拓扑排序】
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】
Dying Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tot ...
- 2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】
CSGO Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- 2017 Multi-University Training Contest - Team 9 1002&&HDU 6162 Ch’s gift【树链部分+线段树】
Ch’s gift Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- 2017 Multi-University Training Contest - Team 9 1001&&HDU 6161 Big binary tree【树形dp+hash】
Big binary tree Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 2017 Multi-University Training Contest - Team 1 1003&&HDU 6035 Colorful Tree【树形dp】
Colorful Tree Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 2017 Multi-University Training Contest - Team 1 1006&&HDU 6038 Function【DFS+数论】
Function Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- 2017 Multi-University Training Contest - Team 1 1002&&HDU 6034 Balala Power!【字符串,贪心+排序】
Balala Power! Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 2017 Multi-University Training Contest - Team 1 1011&&HDU 6043 KazaQ's Socks【规律题,数学,水】
KazaQ's Socks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
随机推荐
- Spring Cloud心跳监测
Spring Cloud实现心跳监测,在服务注册和停止时,注册中心能得到通知,并更新服务实例列表 Spring Cloud注册中心添加配置: eureka.server.enable-self-pre ...
- FreeRtos——移植
现在准备的简单程序LED灯的工程目录中增加freertos文件夹: 在 source目录下的portable目录下只留下下面的文件夹: 为什么呢? 把对应文件移植在工程中之后,添加头文件路径如下图: ...
- C语言 · 大数加法
算法提高 大数加法 时间限制:1.0s 内存限制:256.0MB 问题描述 输入两个正整数a,b,输出a+b的值. 输入格式 两行,第一行a,第二行b.a和b的长度均小于1000位. ...
- [Eth]Mac/Phy/mdio/Rgmii
转自:http://www.cnblogs.com/zxc2man/p/3769777.html 1. MDIO(Management Data Input/Output),对G比特以太网而言,串行通 ...
- Okra框架(一) 简介
Okra是一个构建在Netty框架和Disruptor框架之上轻量级JAVA服务器框架. 使用Netty实现高性能,可灵活扩展的网络通信,使用Disruptor实现高吞吐量,低延迟的并发. Okra主 ...
- st16c554
/* * st16c554.c * * TWO ST16C554 driver for AMCC PPC405EP * * Author: Li Zhi You/Zhu jiang <godis ...
- PHP——自定义函数
<?php //定义有默认值的函数 function Main3($f=5,$g=6) { echo $f*$g; } Main3(2,3); echo "<br />&q ...
- LigerUI 树状列表折叠显示
http://blog.csdn.net/haojuntu/article/details/8626040 —————————————————————————————————————————————— ...
- Throw是一个语句,用来做抛出例外的功能
当我们自己定义一个例外类的时候必须使其继承excepiton或者RuntimeException. Throw是一个语句,用来做抛出例外的功能. 而throws是表示如果下级方法中如果有例外抛出,那么 ...
- java----内部类与匿名内部类的各种注意事项与知识点
Java 内部类分四种:成员内部类.局部内部类.静态内部类和匿名内部类.1.成员内部类: 即作为外部类的一个成员存在,与外部类的属性.方法并列.注意:成员内部类中不能定义静态变量,但可以访问外部类的所 ...