/* HDU 6168 - Numbers [ 思维 ] | 2017 ZJUT Multi-University Training 9 题意: .... 分析: 全放入multiset 从小到大,慢慢筛 */ #include <bits/stdc++.h> using namespace std; const int N = 125250; int n, s[N]; int a[N], cnt; multiset<int> st; multiset<int>::it…
题目链接 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new number (ai+aj). These new numbers could make up a new sequence b1,b2,...,bn(n−1)/2. LsF wants to make some trouble. While zk is sleeping, Ls…
Numbers Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 514    Accepted Submission(s): 270 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a…
/* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问两串是否匹配 分析: dp[i][j] 代表B[i] 到 A[j]全部匹配 然后根据三种匹配类型分类讨论,可以从i推到i+1 复杂度O(n^2) */ #include <bits/stdc++.h> using namespace std; const int N = 2505; int t;…
/* HDU 6162 - Ch’s gift [ LCA,线段树 ] | 2017 ZJUT Multi-University Training 9 题意: N节点的树,Q组询问 每次询问s,t两节点之间的路径上点权值在[a,b]之间的点权总和 分析: 求出每个询问的LCA,然后离线 按dfs顺序更新树状数组,即某点处树状数组中存的值为其所有祖先节点的值 每个点处对答案的贡献为: 当其为第 i 个 lca 时, ans[i] -= 2 * query(a,b) , 再特判该节点 当其为第 i…
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛初始值是1500,变化了几次,得到的正确结果和bug后的是否相等.(Tourist大佬好 Y(^o^)Y) #include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { in…
本文首发于个人博客https://kezunlin.me/post/95370db7/,欢迎阅读最新内容! keras multi gpu training Guide multi_gpu_model import tensorflow as tf from keras.applications import Xception from keras.utils import multi_gpu_model import numpy as np G = 8 batch_size_per_gpu =…
个人感觉题解的复杂度很玄,参不透,有没有大佬讲解一下- - /* HDU 6102 - GCDispower [ 数论,树状数组] | 2017 Multi-University Training Contest 6 题意: 给定排列 a[N], M 组 L,R 求解 ∑ [ L <= i < j < k <= R ] [ GCD(a[i], a[j]) == a[k] ] * a[k] 限制:N, M <= 1e5 分析: 数论角度一般考虑枚举 k,由于是区间询问,且贡献有…
/* HDU 6098 - Inversion [ 贪心,数论 ] | 2017 Multi-University Training Contest 6 题意: 求出所有B[i] = max(A[j]) [j % i != 0] 分析: 排个序从大到小找第一个不是它倍数的数. 至多扫倍数的个数,均摊复杂度O(nlogn) */ #include <bits/stdc++.h> using namespace std; struct Node { int x, i; }; bool cmp(No…
/* HDU 6105 - Gameia [ 非平等博弈 ] | 2017 Multi-University Training Contest 6 题意: Bob 可以把一个点和周围所有点都染黑,还有 k 次割掉一条边的操作 Alice 可以把一个点染白 A先B后,问谁赢 分析: 如果图中不存在两两匹配,则Bob输 每一次两两匹配都需要一次割边,除了最后一次 如果没能力割边,Bob输 */ #include <bits/stdc++.h> using namespace std; int t,…
比赛的时候一直念叨链表怎么加速,比完赛吃饭路上突然想到倍增- - /* HDU 6107 - Typesetting [ 尺取法, 倍增 ] | 2017 Multi-University Training Contest 6 题意: 文章包含N个字符串和 1 个图片 字符串之间要求空 1 格 告诉你纸张宽度 W 固定,图片的左右留白宽度 dw, W-pw-dw 固定 每次询问给定图片的高h和首行x 问 字符串加图片总共占多少行 分析: nxt[W][i] = j 代表 行宽为 W 时第 i 个…
思路来自题解和一些博客 最麻烦的是样例没啥用- - /* HDU 6046 - hash [ hash,鸽巢 ] | 2017 Multi-University Training Contest 2 题意: 给出一个1e3*1e3的矩阵以及 一个 生成1e6*1e6的矩阵的随机函数 在1e6*1e6的矩阵中找到1e3*1e3的矩阵的位置 分析: 将1e3*1e3的矩阵每一个位置压入哈希表中,哈希值为其与之后63位所组成64位的值(不满64位就不压入) 由于 2^64 远大于 1e12 故可认为哈…
/* HDU 6048 - Puzzle [ 思维,结论 ] | 2017 Multi-University Training Contest 2 题意: 类似华容道的问题, N*M 的矩阵中N*M-1个元素按一定要求打乱,每次可以把一个和空格有公共边的块和空格交换 问能否还原局面:从上到下从左到右,依次填 1,2,3,… 右下角为空. 分析: 结论1:将原矩阵看作从左到右从上到下的数列,任意操作不改变 逆序对数量的奇偶性 结论2:任意局面一定能还原到 除了最右下角2*2方格中的3个数字,剩下的…
/* HDU 6053 - TrickGCD [ 莫比乌斯函数,筛法分块 ] | 2017 Multi-University Training Contest 2 题意: 给出数列 A[N],问满足: 1 <= B[i] <= A[i] ; 对任意(l, r) (1<=l<=r<=n) ,使得 gcd(bl,...br) >= 2 ; 的 B[N] 数列的个数 分析: 设 gcd(b1,...bn) = k (k >= 2),此时 k 对答案的贡献为 (a1/k)…
/* HDU 6038 - Function [ 置换,构图 ] 题意: 给出两组排列 a[], b[] 问 满足 f(i) = b[f(a[i])] 的 f 的数目 分析: 假设 a[] = {2, 0, 1} 则 f(0) = b[f(2)] f(1) = b[f(0)] f(2) = b[f(1)] 即 f(0) = b[b[b[f(0)]]] f(1) = b[b[b[f(1)]]] f(2) = b[b[b[f(2)]]] 由于将 a[i]->i 连边可以得到不相交的多个循环 可以看出…
TrickGCD Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2523    Accepted Submission(s): 965 Problem Description You are given an array A , and Zhu wants to know there are how many different a…
Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1610    Accepted Submission(s): 755 Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1.…
Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5522 Description 给n个数A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A​1​​,A​2​​....A​n​​,从中选3个位置不同的数A,B和C,问是否有一种情况满足A-B=C. Input There are multiple test cases, no mo…
Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0Special Judge Problem Description A permutation p1,p2,...,pn of 1,2,...,n is called a lucky permutatio…
OO's Sequence                                                          Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                                                                             T…
P2723 丑数 Humble Numbers 题目背景 对于一给定的素数集合 S = {p1, p2, ..., pK},考虑一个正整数集合,该集合中任一元素的质因数全部属于S.这个正整数集合包括,p1.p1*p2.p1*p1.p1*p2*p3...(还有其 它).该集合被称为S集合的“丑数集合”.注意:我们认为1不是一个丑数. 题目描述 你的工作是对于输入的集合S去寻找“丑数集合”中的第N个“丑数”.所有答案可以用longint(32位整数)存储. 补充:丑数集合中每个数从小到大排列,每个丑…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5585 思路:对于2和5只须看最后一位数,对于三看所有位的数字之和就行 #include<stdio.h> #include<math.h> #include<stdlib.h> #include<string.h> #include<iterator> #include<iostream> #include<algorithm>…
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so he didn't fix the roof of his house. Youssef's roof is 1-D, and it contains n holes that make the water flow into the house, the position of hole i is…
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be the Champion, there are n universities, the ith of them has exactly ai contestants. No one knows what is the official number of contestants in each team…
Description Rami went back from school and he had an easy homework about bitwise operations (and,or,..) The homework was like this : You have an equation : " A | B = C " ( this bar '|' means OR ) you are given the value of A and B , you need to…
Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 460    Accepted Submission(s): 283 Problem Description There is a number N.You should output "YES" if N is a multiple of 2, 3 or 5,ot…
Distinct Values Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2298    Accepted Submission(s): 740 Problem Description Chiaki has an array of n positive integers. You are told some facts about…
http://acm.hdu.edu.cn/showproblem.php?pid=5181 题意: 有一个栈,其中有n个数1~n按顺序依次进入栈顶,在某个时刻弹出. 其中m个限制,形如数字A必须在数字B之前弹出. 求方案总数   dp[i][j]表示数字i~j的出栈方案数 枚举最后一个出栈的数k,若k合法 dp[i][j]+=dp[i][k]*dp[k+1][j] 如何判断k是否合法?   对于一组i,j,k来说,它的弹出顺序是 [i,k-1]早于[k+1,j]早于k 对于一个限制 A必须在B…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6212 解法:看了眼题就发现这个BZOJ 1032不是一毛一样?但是BZOJ上那是个巨坑,数据有错,原来A的是一个假题..2333,但是我并不知道POJ上也有这个题2333...网赛现场没做出来,感觉现场做出来的很多都知道这个题是原题吧..参考这个论文:http://www.docin.com/p-685411874.html 解法:这个题主要是区间DP的转移怎么写? 有三种消除方式: 1.直接将区间…
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers. Write a program to find and pri…