HDU 5045 5047 5050 5053

太菜了,名额差点没保住。吓尿。。赶紧开刷树链抛分

5045:状压DP。压缩10个人。因为两个人不能差2以上,所以能够用01表示

5047:推推公式就可以,每次交线多4条

5050:求GCD。用java大叔就可以

5053:签到题

代码:

5045:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; const int N = 1025; int t, n, m, vis[N][N];
double dp[N][N], g[15][N]; double dfs(int u, int num) {
if (u == (1<<n) - 1) u = 0;
if (vis[u][num]) return dp[u][num];
vis[u][num] = 1;
if (num == m) return dp[u][num] = 0;
dp[u][num] = 0;
for (int i = 0; i < n; i++) {
if (u&(1<<i)) continue;
dp[u][num] = max(dp[u][num], dfs(u|(1<<i), num + 1) + g[i][num]);
}
return dp[u][num];
} int main() {
int cas = 0;
scanf("%d", &t);
while (t--) {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
scanf("%lf", &g[i][j]);
}
}
memset(vis, 0, sizeof(vis));
printf("Case #%d: %.5lf\n", ++cas, dfs(0, 0));
}
return 0;
}

5047:

#include <cstdio>
#include <cstring> typedef long long ll; const ll MOD = 100000000;
int t;
ll n; struct Num {
ll num[5];
int len;
Num() {
len = 0;
memset(num, 0, sizeof(num));
}
void init(ll x) {
len = 0;
if (x == 0) {
len = 1;
num[0] = 0;
return;
}
while (x) {
num[len++] = x % MOD;
x /= MOD;
}
} Num operator * (Num c) {
Num ans;
for (int i = 0; i < len; i++) {
for (int j = 0; j < c.len; j++) {
ans.num[i + j] += num[i] * c.num[j];
}
}
ans.len = len + c.len;
for (int i = 0; i < ans.len; i++) {
ans.num[i + 1] += ans.num[i] / MOD;
ans.num[i] %= MOD;
}
return ans;
} void add() {
while (len && num[len - 1] == 0) len--;
num[0] += 2;
for (int i = 0; i < len; i++) {
num[i + 1] += num[i] / MOD;
num[i] %= MOD;
}
if (num[len]) len++;
while (len && num[len - 1] == 0) len--;
} void print() {
while (len && num[len - 1] == 0) len--;
for (int i = len - 1; i >= 0; i--) {
if (i == len - 1) printf("%I64d", num[i]);
else printf("%08I64d", num[i]);
}
printf("\n");
}
} A, B; int main() {
int cas = 0;
scanf("%d", &t);
while (t--) {
scanf("%I64d", &n);
A.init(n - 1);
B.init(8 * n + 1);
Num c = (A * B);
c.add();
printf("Case #%d: ", ++cas);
c.print();
}
return 0;
}

5050:

import java.util.*;
import java.math.*;
import java.io.*; public class Main {
public static BigInteger gcd(BigInteger a, BigInteger b) {
if (b.equals(BigInteger.valueOf(0)) == true) return a;
return gcd(b, a.mod(b));
}
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int t;
t = cin.nextInt();
String a, b;
BigInteger aa, bb;
for (int cas = 1; cas <= t; cas++) {
a = cin.next();
b = cin.next();
aa = BigInteger.valueOf(0);
bb = BigInteger.valueOf(0);
for (int i = 0; i < a.length(); i++) {
aa = aa.multiply(BigInteger.valueOf(2));
if (a.charAt(i) == '1') aa = aa.add(BigInteger.valueOf(1));
}
for (int i = 0; i < b.length(); i++) {
bb = bb.multiply(BigInteger.valueOf(2));
if (b.charAt(i) == '1') bb = bb.add(BigInteger.valueOf(1));
}
BigInteger tmp = gcd(aa, bb);
String ans = "";
while (tmp.equals(BigInteger.valueOf(0)) == false) {
if (tmp.mod(BigInteger.valueOf(2)).equals(BigInteger.valueOf(1))) ans += '1';
else ans += '0';
tmp = tmp.divide(BigInteger.valueOf(2));
}
System.out.print("Case #");
System.out.print(cas);
System.out.print(": ");
for (int i = ans.length() - 1; i >= 0; i--)
System.out.print(ans.charAt(i));
System.out.println();
}
}
}

5053:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
using namespace std; typedef long long ll; int t;
ll a, b; int main() {
int cas = 0;
scanf("%d", &t);
while (t--) {
scanf("%I64d%I64d", &a, &b);
ll sum = 0;
for (ll i = a; i <= b; i++)
sum += i * i * i;
printf("Case #%d: %I64d\n", ++cas, sum);
}
return 0;
}

HDU 5045 5047 5050 5053(上海网络赛E,F,I,L)的更多相关文章

  1. HDU 5045 状压DP 上海网赛

    比赛的时候想的是把n个n个的题目进行状压 但这样不能讲究顺序,当时精神面貌也不好,真是挫死了 其实此题的另一个角度就是一个n个数的排列,如果我对n个人进行状压,外面套一个按题目循序渐进的大循环,那么, ...

  2. 2019上海网络赛 F. Rhyme scheme 普通dp

    Rhyme scheme Problem Describe A rhyme scheme is the pattern of rhymes at the end of each line of a p ...

  3. HDU 4768 Flyer (2013长春网络赛1010题,二分)

    Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  4. HDU 4747 Mex (2013杭州网络赛1010题,线段树)

    Mex Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submis ...

  5. HDU 4733 G(x) (2013成都网络赛,递推)

    G(x) Time Limit: 2000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  6. hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)

    题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...

  7. 2014上海网络赛 HDU 5053 the Sum of Cube

    水 #include <stdio.h> #include <stdlib.h> #include<math.h> #include<iostream> ...

  8. hdu 5053 the Sum of Cube(上海网络赛)

    the Sum of Cube Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  9. hdu 5476 Explore Track of Point(2015上海网络赛)

    题目链接:hdu 5476 今天和队友们搞出3道水题后就一直卡在这儿了,唉,真惨啊……看着被一名一名地挤出晋级名次,确实很不好受,这道恶心的几何题被我们3个搞了3.4个小时,我想到一半时发现样例输出是 ...

随机推荐

  1. 设置并删除Dreamweaver自动生成的_notes文件夹

    在使用Dreamweaver做项目时站点下面的每个文件夹里面都会自动生成一个_notes文件夹,删除之后马上又会再次生成.最近做项目时,有童鞋一不小心把所有的_notes文件夹全部存回到SVN上面了, ...

  2. squid.conf 的cache_peer 详解

    通过squid.conf配置文件中的cache_peer选项来配置代理服务器阵列,通过其他的选项来控制选择代理伙伴的方法.Cache_peer的使用格式如下: cache_peer hostname ...

  3. 最新IP地址数据库Dat格式-高性能高并发版(2019年3月)

    最新IP地址数据库->Dat  二进制文件 高性能高并发-qqzeng-ip.dat 格式 全球IP数据库-20190301-Dat 版                国内IP数据库-20190 ...

  4. vim常用操作之复制剪切粘贴,注释取消注释,多行缩进等

    进入vim按下v键,选择要操作的对象 按下y复制,d剪切,p粘贴 >缩进,<取消缩进 按下esc退出操作 按下ctrl+v,选择要操作对象, 按下大写I,写入注释符号,按下d取消注释 按下 ...

  5. 本地启动tomcat的时候报内存溢出错误:java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space

    问题分析: PermGen space的全称是Permanent Generation space,是指内存的永久保存区域,这块内存主要是被JVM存放Class和Meta信息的,Class在被Load ...

  6. leetcode题解:Valid Palindrome(判断回文)

    题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...

  7. ~/.bash_profile介绍

    mac和linux终端一般用bash来进行解析.当bash在读完了整体环境变量的/etc/profile并借此调用其他配置文件后,接下来则是会读取用户自定义的个人配置文件.bash读取的文件总共有三种 ...

  8. 常见java异常

    1. java.lang.NullPointerException(空指针异常)  调用了未经初始化的对象或者是不存在的对象 经常出现在创建图片,调用数组这些操作中,比如图片未经初始化,或者图片创建时 ...

  9. PV、UV

    1.什么是PV值 PV(page view)即页面浏览量或点击量,是衡量一个网站或网页用户访问量.具体的说,PV值就是所有访问者在24小时(0点到24点)内看了某个网站多少个页面或某个网页多少次.PV ...

  10. dubbo接口压测工具stresstester使用

    dubbo接口压测工具stresstester使用 https://blog.csdn.net/u013822349/article/details/79412719