昨晚在开赛前5分钟注册的,然后比赛刚开始就掉线我就不想说了(蹭网的下场……),只好用手机来看题和提交,代码用电脑打好再拉进手机的(是在傻傻地用手机打了一半后才想到的办法)。

  1001,也就是 hdu 5174,题意很难叙述了,自己看题吧,这题有数据溢出的风险,我竟然是AC了一发才发觉的(只过了小数据),幸好后来改后赶紧再交一遍才不至于被人hack,因为需要对数据去重,我不想用数组模拟,便尝试下用 map了,可是我的奇葩 map ( ~′⌒`~),连我自己都感到无语了:

 #include<cstdio>
#include<map>
#include<iostream>
using namespace std;
typedef long long LL;
const int INF= 0x7fffffff; typedef map<int,int>::iterator mit; mit operator +(const mit &p, int i)
{
mit it= p;
return ++it;
} mit operator -(const mit &p, int i)
{
mit it= p;
return --it;
} int main(){
int n,i,x,k= ;
map<int,int> m;
while(~scanf("%d",&n)){
m.clear();
for(i=; i<=n; ++i){
cin>>x;
if(m.find(x)!=m.end()) ++m[x];
else m.insert(pair<int,int>(x,));
}
if(m.size()==) {
printf("Case #%d: -1\n",++k);
continue;
}
mit st= m.begin(), it= st, ed= m.end()-; int ans= ;
for(++it; it!=ed; ++it)
if(((LL)it->first+ (it-)->first)%INF == (it+)->first) ans+= it->second; if(((LL)st->first+ ed->first)%INF== (st+)->first) ans+= st->second;
if(((ed-)->first+ (LL)ed->first)%INF== st->first) ans+= ed->second;
printf("Case #%d: %d\n",++k,ans);
}
return ;
}

  上网找了下,发觉有个做法很不错的,用数组和 map一起模拟,不用什么 insert啊,find啊,还有连迭代器都不用,编码能力确实比我高多了,不得不赞:

 #include <stdio.h>
#include <string.h>
#include <map>
#include <algorithm>
#define INT_MAX 2147483647
using namespace std; int main()
{
int n, k = ;
long long ans;
long long a[];
while(~scanf("%d", &n))
{
ans = ;
map<int, int> mm;
int cnt = , tmp;
for(int i = ; i < n; i++)
{
scanf("%d", &tmp);
if(!mm[tmp])
{
a[cnt++] = tmp;
}
mm[tmp]++;
}
if(cnt == )
{
printf("Case #%d: -1\n", k++);
continue;
}
sort(a, a+cnt);
for(int i = ; i < cnt; i++)
{
if((a[(i - + cnt) % cnt] + a[(i - + cnt) % cnt]) % INT_MAX == a[i])
{
ans += mm[a[(i - + cnt) % cnt]];
}
}
printf("Case #%d: %d\n", k++, ans);
}
return ;
}

  1002,hdu 5175,是今天中午才做的,一开始还以为要用到什么高大上的数论定理,后来才发现不过是普通的暴力就行,枚举 n 所有的因数 i 看是否满足  gcd(n, n^i)== i 即可,真正的卡人是在输出格式上:

 #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL; LL gcd(LL a, LL b) { return b==? a: gcd(b,a%b); } LL digit[]= {}, ans[]; void solve(LL n)
{
if(n==){
puts("0\n");
return;
}
int num= ;
LL m= sqrt(n+0.5);
for(LL i=; i<=m; ++i)
if(n%i==){
digit[++num]= i;
if(n/i!=i) digit[++num]= n/i;
}
int c= ;
for(int i=; i<=num; ++i){
LL tmp= n^digit[i];
if(tmp<n && gcd(n,tmp)==digit[i]) ans[c++]= tmp;
}
sort(ans,ans+c);
printf("%d\n",c);
for(int i=; i<c-; ++i)
printf("%I64d ",ans[i]);
if(c) printf("%I64d\n",ans[c-]);
else puts("");
} int main()
{
int k=;
LL n;
while(~scanf("%I64d",&n)){
printf("Case #%d:\n",++k);
solve(n);
}
return ;
}

  情人节,唉~也算是收到了意料之外的礼物,具体就不说了~~

BestCoder Valentine's Day Round的更多相关文章

  1. Valentine's Day Round hdu 5176 The Experience of Love [好题 带权并查集 unsigned long long]

    传送门 The Experience of Love Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Ja ...

  2. Valentine's Day Round 1001.Ferries Wheel(hdu 5174)解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5174 题目意思:给出 n 个人坐的缆车值,假设有 k 个缆车,缆车值 A[i] 需要满足:A[i−1] ...

  3. hdu 5175(数论)

    Misaki's Kiss again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  4. BestCoder Round #89 02单调队列优化dp

    1.BestCoder Round #89 2.总结:4个题,只能做A.B,全都靠hack上分.. 01  HDU 5944   水 1.题意:一个字符串,求有多少组字符y,r,x的下标能组成等比数列 ...

  5. BestCoder Round #90 //div all 大混战 一题滚粗 阶梯博弈,树状数组,高斯消元

    BestCoder Round #90 本次至少暴露出三个知识点爆炸.... A. zz题 按题意copy  Init函数 然后统计就ok B. 博弈 题  不懂  推了半天的SG.....  结果这 ...

  6. bestcoder Round #7 前三题题解

    BestCoder Round #7 Start Time : 2014-08-31 19:00:00    End Time : 2014-08-31 21:00:00Contest Type : ...

  7. Bestcoder round #65 && hdu 5593 ZYB's Tree 树形dp

    Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submissio ...

  8. Bestcoder round #65 && hdu 5592 ZYB's Premutation 线段树

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submissio ...

  9. 暴力+降复杂度 BestCoder Round #39 1002 Mutiple

    题目传送门 /* 设一个b[]来保存每一个a[]的质因数的id,从后往前每一次更新质因数的id, 若没有,默认加0,nlogn复杂度: 我用暴力竟然水过去了:) */ #include <cst ...

随机推荐

  1. 每日一九度之 题目1043:Day of Week

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7336 解决:2563 题目描述: We now use the Gregorian style of dating in Russia. ...

  2. IIS装好后,局域网不能访问

    IIS默认安装完成后,可以通过http:\\localhost或http:\\127.0.0.1或者http:\\ip地址访问,但是局域网内却不能通过IP来访问,通常只需要将防火墙关掉就好了,也在在防 ...

  3. hdu4924 Football Manager

    这题上来我是没有思路的.因为目标值关涉到的因素太多而直接枚举的复杂度又太高. 目标值由两部分合成,一部分是队员的CA和与PA和,另一部分是队员之间的relationship. 前者是简单的代数累加,而 ...

  4. Shuffle'm Up 分类: 函数 POJ 查找 2015-08-09 17:01 6人阅读 评论(0) 收藏

    Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7529 Accepted: 3466 Descript ...

  5. Winsock系列函数 及 Socket通信流程

    Socket是一种网络通信机制   Winsock系列函数   1. Socket 创建socket   2. Connect 尝试连接远端Socket   3. Send 在某个Socket 向远端 ...

  6. duilib -- Label控件的bug(转载)

    转载:http://blog.csdn.net/rundll64/article/details/24823809?locationNum=6&fps=1 发现LabelUI的[属性列表.XM ...

  7. VirtualBox中安装CentOS-6.6虚拟机(转载)

    1. 下载 可以到官网下载,http://mirror.centos.org/centos/ 如果下载速度太慢的话,也可以到163镜像下载: http://mirrors.163.com/centos ...

  8. 我的android学习经历21

    怎样在代码文件中修改控件的高低 有些时候使用setHight()或者setWidth()不管用就需要使用别的方法,下面有一种方法 你使用的布局.LayoutParams lp = new 你使用的布局 ...

  9. MeshLab中进行点云配准

    MeshLab是一个开源.可移植和可扩展的三维几何处理系统,主要用于交互处理和非结构化编辑三维三角形网格.它支持多种文件格式: import:PLY, STL, OFF, OBJ, 3DS, COLL ...

  10. 读取视屏文件,保存帧图片为ppm文件

    ffmpeg跟sdl的学习过程:一.版本信息:ffmpeg-3.0.2.tar.bz2SDL2-2.0.4.tar.gz二.编译过程:1.ffmgeg的编译:./configure --enable- ...