#include<iostream> #include<cmath> using namespace std; const int maxn = 32768; long long a[maxn],s[maxn]; void init(){ s[0] = 0; a[1] = s[1] = 1; for(int i=2;i<maxn;i++){ a[i] = a[i-1]+(int)log10((double)i)+1; s
#include<iostream> #include<cstring> using namespace std; int data[10]; void reverse(char*s,char*t){ for(int i=0;i<10;i++){ data[i] = 0; } for(int i=0;i<strlen(s);i++){ data[s[i]-'0']++; } in
Cleaning Shifts POJ - 2376 AYIT-2021 609暑假集训第一周上 搜索和贪心 Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and
Saruman’s Army POJ - 3069 AYIT-2021 609暑假集训第一周上 搜索和贪心 Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs,
#include<iostream> using namespace std; const int maxn = 1005; int n,data[maxn],dp[maxn]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin>>n; for(int i=1;i<=n;i++){ cin>>data[i]; dp[i] = 1;
#include<iostream> using namespace std; const int maxn = 355; int n,data[maxn][maxn],dp[maxn]; int main(){ cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ cin>>data[i][j]; } } for(i
题目链接:http://poj.org/problem?id=2777 颜色数量很少,所以状压进 \(int\),线段树维护即可 #include<cstdio> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; const int maxn = 100010; int n, T, m; struct Node{ int tag; int col
Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 197361 Accepted: 47168 Description Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national
http://poj.org/problem?id=1852 题目大意 army 陆军,大军 reside 居住 一群蚂蚁走在长为 1 c m 1cm 1cm的水平杆上,每个的速度是
题目: https://vjudge.net/problem/POJ-3279 参考的题解: POJ-3279 经典翻转问题_越努力越幸运—liupu-CSDN博客 翻转吧!POJ 3279! - 知乎 (zhihu.com) 思路:把第一排的01串给枚举出来(直接按照字典序来) 从第二排开始把每种情况用b存下来 检查每种情况最后一排有没有黑色 如果全白从
传送门 分析 系统的刷一下换根DP这个专题 首先如果我们固定一个根节点的话,可以在 O ( n ) O(n) O(n)的复杂度
算是一道水题,但是被折腾并不幸多次贡献WA... 太久不写代码略显生疏。思路其实是有的,大体分为两种 第一种是开始尝试的,但就是这里开始不停找不到出路,不明白是何方测评神仙数据卡着,discuss里的有问题的测试数据过的都没问题。思路如下: 之前一道题的练习,领悟到AC自动机本质上是构建
一道水题,不过很多细节没注意结果拖了很久还一直WA,总之用堆来记录括号,整体上还是比较简单的,但是细节一定要想清楚。 #include <iostream> #include <algorithm> #include <queue> #include <string> #include <vector> #include <cstdio> #include <cstdlib> #include <cstring>
原题链接 考察:贪心 错误思路: 对于每个任务,按d,a顺序排序,如果不能按时完成就付钱使得按时完成. 思路: 不一定要压当前任务的时间,我们可以压花费更小的任务时间,使得超时任务按时完成. Code #include <iostream> #include <cstring> #include <algorithm> #include <c
POJ 1463 Strategic game 又是外面的 OJ ... 火车头带着交了,Time Limit Exceeded. 哦,原来有多测。 while(scanf("%d", &n) != EOF) 再交 Accepted. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #def
开始使用DAG的DP思路解决,然而忽略一个特殊情况,两个box倘若相同尺寸,此时就不满足DAG的限制了 这道题取了一个非常巧妙的思路,因为box的l, m是固定的(也就是说不存在可以旋转的问题),这道题巧妙的利用LIS的思路解决,在学习LIS的过程中,还顺道了解了一个O(nlogn)的算法 #include <iostream>
找找手感一道题,有些类似于uva此前做过的一道判断照片字母形状的题,利用DFS求联通分量。 这里要格外注意边缘碰到0的情况的讨论,当遍历一个连通分量时,整个连通分量必须遍历完再推出,不可以分几次遍历同一连通分量,这是DEBUG好久得出的教训 #include <iostream> #include <algorithm> #i
生日蛋糕 题目链接http://poj.org/problem?id=1190 Time Limit: 1000MS Memory Limit: 10000K Description 7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。 设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱。当i < M时,要
棋盘问题 题目链接http://poj.org/problem?id=1321 Time Limit: 1000MS Memory Limit: 10000K Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k
Mayor’s posters Time Limit: 1000MS Memory Limit: 65536K 题目链接http://poj.org/problem?id=2528 Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all p
Bookshelf 2 题目链接http://poj.org/problem?id=3628 Time Limit: 1000MS Memory Limit: 65536K Description Farmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only available space is
题意 ftiasch 有 N 个物品, 体积分别是 W1, W2, ..., WN。 由于她的疏忽, 第 i 个物品丢失了。 “要使用剩下的 N - 1 物品装满容积为 x 的背包,有几种方法呢?” -- 这是经典的问题了。她把答案记为 Count(i, x) ,想要得到所有1 <= i <= N, 1 <= x <= M的 Count(i, x)
传送门 https://vjudge.net/problem/POJ-2001 题目大意就是求每一个字符串的最短前缀,并且这个前缀其他字符串都没有。 一道trie树板子题。建树的时候,每一个结点维护的是经过这个状态的字符串有多少个。然后查询的时候,对于每一个字符串,从头开始跑trie树,找到第一个数是1的结点
原题链接 考察:数位dp 思路: 入门题(然后做了一个小时) 这里预处理方案数是用组合数.如果我们直接套模板会发现答案不对,因为我们不同数字的二进制位数不同,前导零不应该被计入. 先算出n有的二进制位数符合条件个数,然后再计算二进制位数比n小的即可. Code #include <
POJ 3280 Cheapest Palindrome(区间dp) 此题为取两端的区间dp。 分情况讨论: 1. a i = a