BestCoder Round #16

题目链接

这场挫掉了,3挂2,都是非常sb的错误 23333 QAQ

A:每一个数字。左边个数乘上右边个数,就是能够组成的区间个数,然后乘的过程注意取模不然会爆掉

B:dp,dp[i][2]记录下第一长的LIS,和第二长的LIS。哎,转移的时候一个地方写挫掉了导致悲剧啊QAQ

C:首先假设知道Nim游戏的,就非常easy转化问题为。一些数字能否选几个能否异或和为0。那么就是每一个数字拆成40位。然后每一位异或和为0。这样就能够构造出40个方程,然后高斯消元求解,假设有自由变元就是有解。由于必定有一个全是0的解。而由于不能全取,所以这个解是错误的,那么就变成推断自由变元个数了,还是一个地方写挫掉了悲剧啊QAQ

代码:

A:

#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
using namespace std; typedef long long ll;
const int N = 500005;
const ll MOD = 1000000007; int t, n;
ll a; int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
ll ans = 0;
for (ll i = 0; i < n; i++) {
scanf("%I64d", &a);
ans = (ans + a * (n - i) % MOD * (i + 1) % MOD) % MOD;
}
printf("%I64d\n", ans);
}
return 0;
}

B:

#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std; const int N = 1005; int t, n, a[N], dp[N][2]; int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
int ans0 = 0, ans1 = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
dp[i][0] = 1; dp[i][1] = 0;
for (int j = 1; j < i; j++) {
if (a[i] <= a[j]) continue;
if (dp[i][0] <= dp[j][0] + 1) {
dp[i][1] = dp[i][0];
dp[i][0] = dp[j][0] + 1;
} else if (dp[i][1] < dp[j][0] + 1) {
dp[i][1] = dp[j][0] + 1;
}
dp[i][1] = max(dp[i][1], dp[j][1] + 1);
}
if (ans0 <= dp[i][0]) {
ans1 = ans0;
ans0 = dp[i][0];
} else if (ans1 < dp[i][0]) ans1 = dp[i][0];
ans1 = max(ans1, dp[i][1]);
}
printf("%d\n", ans1);
}
return 0;
}

C:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; typedef long long ll; const int N = 1005;
int t, n, A[45][N];
ll a; int rank(int m, int n) {
int i = 0, j = 0, k, r, u;
while (i < m && j < n) {
r = i;
for (k = i; k < m; k++)
if (A[k][j]) {r = k; break;}
if (A[r][j]) {
if (r != i) for(k = 0; k <= n; k++) swap(A[r][k], A[i][k]);
for (u = i + 1; u < m; u++) if (A[u][j])
for (k = i; k <= n; k++) A[u][k] ^= A[i][k];
i++;
}
j++;
}
return n - i;
} int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
memset(A, 0, sizeof(A));
for (int i = 0; i < n; i++) {
scanf("%lld", &a);
for (int j = 0; j < 40; j++)
A[j][i] = (a>>j)&1;
}
printf("%s\n", rank(40, n) > 0 ? "Yes" : "No");
}
return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

BestCoder Round #16的更多相关文章

  1. HDU5088——Revenge of Nim II(高斯消元&矩阵的秩)(BestCoder Round #16)

    Revenge of Nim II Problem DescriptionNim is a mathematical game of strategy in which two players tak ...

  2. HDU5087——Revenge of LIS II(BestCoder Round #16)

    Revenge of LIS II Problem DescriptionIn computer science, the longest increasing subsequence problem ...

  3. HDU5086——Revenge of Segment Tree(BestCoder Round #16)

    Revenge of Segment Tree Problem DescriptionIn computer science, a segment tree is a tree data struct ...

  4. hdu 5086 Revenge of Segment Tree(BestCoder Round #16)

    Revenge of Segment Tree                                                          Time Limit: 4000/20 ...

  5. bestcoder Round #7 前三题题解

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

  6. hdu5631 BestCoder Round #73 (div.2)

    Rikka with Graph  Accepts: 123  Submissions: 525  Time Limit: 2000/1000 MS (Java/Others)  Memory Lim ...

  7. hdu5630 BestCoder Round #73 (div.2)

    Rikka with Chess  Accepts: 393  Submissions: 548  Time Limit: 2000/1000 MS (Java/Others)  Memory Lim ...

  8. (BestCoder Round #64 (div.2))Array

    BestCoder Round #64 (div.2) Array 问题描述 Vicky是个热爱数学的魔法师,拥有复制创造的能力. 一开始他拥有一个数列{1}.每过一天,他将他当天的数列复制一遍,放在 ...

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

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

随机推荐

  1. CentOS 7 安装MySql Server 5.6

    1. 安装MySql Server 在/etc/yum.repos.d/目录下添加以下文件mysql-community.repo文件,内容如下: [mysql56-community] name=M ...

  2. JAVA 计算地球上任意两点(经纬度)距离

    /** * 计算地球上任意两点(经纬度)距离 * * @param long1 * 第一点经度 * @param lat1 * 第一点纬度 * @param long2 * 第二点经度 * @para ...

  3. mysql事务、触发器、视图、存储过程、函数

    存储过程: procedure 概念类似于函数,就是把一段代码封装起来, 当要执行这一段代码的时候,可以通过调用该存储过程来实现. 在封装的语句体里面,可以用if/else, case,while等控 ...

  4. jar包有嵌套的jar的打包成jar的方法

    1.先写一个类,将其打包成jar包. 代码如下: package com.wjy.jar; public class GetUserName { public String getUserName() ...

  5. WPF换肤之八:创建3D浏览效果

    原文:WPF换肤之八:创建3D浏览效果 上节中,我们展示了WPF中的异步以及界面线程交互的方式,使得应用程序的显示更加的流畅.这节我们主要讲解如何设计一个具有3D浏览效果的天气信息浏览器. 效果显示 ...

  6. hihocoder第42周 3*N骨牌覆盖(状态dp+矩阵快速幂)

    http://hihocoder.com/contest/hiho42/problem/1 给定一个n,问我们3*n的矩阵有多少种覆盖的方法 第41周做的骨牌覆盖是2*n的,状态转移方程是dp[i] ...

  7. iOS执行时与method swizzling

    C语言是静态语言,它的工作方式是通过函数调用,这样在编译时我们就已经确定程序怎样执行的.而Objective-C是动态语言,它并不是通过调用类的方法来执行功能,而是给对象发送消息,对象在接收到消息之后 ...

  8. java 对map排序

    public static Map<String, String> sortMapByKey(Map<String, String> map) { if (map == nul ...

  9. 索尼 LT26I刷机包 X.I.D 增加官方风格 GF A3.9.4 各方面完美

    ROM介 FX_GF_A系列是具有官方风格的.稳定的.流畅的.省电的.新功能体验的.最悦耳音效体验的ROM. FX_GF_A更新日志 ☆ GF_3.9.4 更新信息 ☆ 更新播放器 ☆ 更新adsp数 ...

  10. The app references non-public selectors in payload With Xcode6.1

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: p=591" style="color: rgb(255, 97, 0 ...