ZOJ
文章平均质量分 70
huadong_fcy56
这个作者很懒,什么都没留下…
展开
-
ZOJ2724 Windows Message Queue 裸queue的模拟
题目要求FIFO,如果是FILO呢?把重载里的“>”换成 “>=”即可。#include#include#include#include#include#include#includeusing namespace std;struct in{ string name; int id; int dex; in(string s,int d,int x):nam原创 2017-08-23 11:59:21 · 237 阅读 · 0 评论 -
zoj2277 The Gate to Freedom
传送门题目大意,对n, 求n^n的最左边一位数的大小;如 f(3)=27,ans=27/10=2; f(4)=256,ans=256/10/10=2;原创 2017-08-15 11:08:58 · 171 阅读 · 0 评论 -
ZOJ2067 经典 DP
题目:一个由‘.’和‘#’组成矩形,统计里面'.'组成的矩形的个数。点击打开链接自己写挂了,懒得搞了#include #include #define MAX 110#define inf 0x7fffffffchar a[MAX][MAX];int count[MAX][MAX];int n;int min(int x,int y){ return x<y?x:y;原创 2017-08-19 18:41:08 · 177 阅读 · 0 评论 -
Are We There Yet? (zoj1745)
Are We There Yet? (ZOJ Problem Set - 1745)Are We There Yet?Time Limit: 2 Seconds Memory Limit: 65536 KB Laurie's little brother Joey has been playing Find the Cookie with he原创 2017-08-05 19:12:06 · 192 阅读 · 0 评论 -
zoj1002 Fire Net
Fire NetTime Limit: 2 Seconds Memory Limit:65536 KB Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each repre原创 2017-08-05 19:38:51 · 230 阅读 · 0 评论 -
zoj3961(区间问题)
线性区间扫描 ACM (ACMers' Chatting Messenger) is a famous instant messaging software developed by Marjar Technology Company. To attr原创 2017-08-07 12:06:50 · 275 阅读 · 0 评论 -
ZOJ2286 Sum of Divisors 筛选式打表
我想我是和Segmentation Fault有仇,我一直以为是空间开大的问题,然后一直减少空间,还是SF,谁让n没有给范围了,qwq。教训:以后注意输入范围和开的空间大小。#include#include#include#includeusing namespace std;int a[3400010];int ans[1000011];int sum[3400010];原创 2017-08-21 14:40:06 · 286 阅读 · 0 评论 -
ZOJ2150 Raising Modulo Numbers 快速幂
ZOJ2150快速幂,但是用递归式的好像会栈溢出。#include#include#include#includeusing namespace std;long long M,i;#define LL long long int _work(LL a,LL n){ LL ans=1; while(n){ if(n&1){ an原创 2017-08-21 11:45:25 · 219 阅读 · 0 评论 -
ZOJ2212 Argus 优先队列 结构体
#include #include #include using namespace std;struct In{ int id; int ReturnTime; int period; In(int i, int p):id(i), ReturnTime(p), period(p){} //重载写在在里面又怎么写? };bool operator < (const In原创 2017-08-21 13:26:49 · 302 阅读 · 0 评论 -
ZOJ-2091-Mean of Subsequence (反证法的运用!!)
http://blog.csdn.net/u014355480/article/details/40862041题意:其实就是找后几个数的平均值的最大值!! (贪心策略!要找对)k=1,2,3……n ,记k以及k后面的数的平均值最大的那个k做maxk一旦Roy选了这个maxk , PMH必定会将所选数字长度最大化为什么呢??用反证法证明:转载 2017-08-20 16:19:50 · 186 阅读 · 0 评论 -
zoj 1938 Binomial Showdown 组合数裸基础
Binomial ShowdownTime Limit: 2 Seconds Memory Limit:65536 KB In how many ways can you choose k elements out of n elements, not taking order into account?Write a program to compu原创 2017-08-13 18:21:08 · 189 阅读 · 0 评论 -
zoj2818 Root of the Problem 简单数学 开方
Root of the ProblemTime Limit: 2 Seconds Memory Limit:65536 KB Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approx原创 2017-08-13 17:53:36 · 206 阅读 · 0 评论 -
zoj1871steps 数学 水
zoj1871题目大意:给你一段长度,起始和末尾一步只能是一个单位长度,每一步和前一步长度差不超过一,问恰好走到终点的最小步数。假设前半截一直在+1,后半截直接对称过去,刚刚到则+0,保证了最小步数,剩余的零头+1或者+2.#include#include#includeusing namespace std;int main(){ int m,n,temp,i;原创 2017-08-15 12:35:29 · 162 阅读 · 0 评论 -
ZOJ2401 Zipper 双塔式 DP
遇到双塔DP,写一下。flag是为了避免memset。 #include#include#include#includeusing namespace std;char x[410],y[410],z[410];int map[410][410],L,Lx;//410=210+x bool _find(int flag){ for(int i=1;i<=L;i++) {原创 2017-08-21 20:13:25 · 199 阅读 · 0 评论 -
ZOJ2402 Lenny's Lucky Lotto List 简单DP
Lenny's Lucky Lotto ListsTime Limit: 2 Seconds Memory Limit:65536 KB Lenny likes to play the game of lotto. In the lotto game, he picks a list of N unique numbers in the range from 1原创 2017-08-22 14:35:56 · 244 阅读 · 0 评论 -
ZOJ2975 伪数组压缩+组合数
Kinds of FuwasTime Limit: 2 Seconds Memory Limit:65536 KB In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China as well as becomi转载 2017-08-24 17:40:42 · 240 阅读 · 0 评论 -
ZOJ2110 HDU1010 搜索 Tempter of the Bone
传送门:Tempter of the Bone 大意是给一个矩阵,叫你是否可以在给定的可走路径上不重复地走,在最后一秒走到终点。我用了两个剪枝,且称其为简直001和剪枝002,事实证明001不要都可以,002不要也能过--||。就当练习一下剪枝。特别是002很有用。 if( d %原创 2017-08-15 19:40:25 · 173 阅读 · 0 评论 -
floyd的总结
基础: HDU2112 HDU1874 HDU1869 HDU2066加深对k的理解: HDU1599(最小环) ZOJ3710待续原创 2017-09-22 08:49:14 · 211 阅读 · 0 评论 -
ZOJ 1489 HDU1395 2^x mod n = 1 数学
2^x mod n = 1Time Limit: 2 Seconds Memory Limit:65536 KB Give a number n, find the minimum x that satisfies 2^x mod n = 1.InputOne positive integer on each line, the value of n.原创 2017-08-13 18:57:25 · 166 阅读 · 0 评论 -
ZOJ2965 Accurately Say "CocaCola"! 线性扫描
Accurately Say "CocaCola"!范围找到1——700左右,然后打表就ok了#include#include#includeusing namespace std;bool a[810];int sum[810];int pos[810];void _judge(int v){ if(v%7==0){ a[v]=true; return原创 2017-08-24 15:37:26 · 320 阅读 · 0 评论 -
ZOJ2105 终于找到错误
ZOJ2105:点击打开链接明明思路这么清晰,明明代码这么正确#include#includeint q[110];int main(){ int a,b,n,T; while(~scanf("%d%d%d",&a,&b,&n)&&(a||b||n)) { T=0; q[1]=1;q[2]=1; q[3]=(a*q[2]+b*q[1])%7; for原创 2017-08-20 18:20:05 · 229 阅读 · 0 评论 -
ZOJ2185 简单分块 找规律
初步找大概位置,然后找精确位置,算是简单化的分块吧!#include#include#includeusing namespace std;int c[5000];int num=0;void _get(){ int k=1,m; while(true){ m=(k+1)*k/2; if(m>10000000) break; c[++num]=m;原创 2017-08-21 10:43:17 · 227 阅读 · 0 评论 -
ZOJ2334 Monkey King 并查集 STL
题意:两家原始人(猴)打交道后成为一家猴,打交道时两家分别派出最帅的两位猴子,颜值各自减半,问每次打交道后新家族最帅的猴子的颜值。当然,已经是一家子就没有必要打交道了,因为没有猴希望颜值降低,毕竟还得靠这个吃饭。裸裸的并查集+大根堆:#include#include#include#include#include#includeusing namespace std;原创 2017-08-22 12:19:13 · 209 阅读 · 0 评论 -
ZOJ2345Gold Coins 简单分块
昨天做过一样的题:平方和公式:n*(n+1)*(2n+1)#include#include#includeusing namespace std;int a[150],num;int b[150];int _S(){ char c=getchar();int s=0; while(c'9') c=getchar(); while(c>='0'&&c<='9'){s=s*原创 2017-08-22 12:59:14 · 295 阅读 · 0 评论 -
zoj1383 zoj3418 二进制 基础
传送门题目大意:从末位到首位输出所在位置的值是1的位置。可以用除(2)-> num>>1或减(n^(-n))while(num != 0) { if(num & 1) { if(t!=0) printf(" "); printf("%d", iDigit);原创 2017-08-15 14:24:10 · 255 阅读 · 0 评论 -
zoj1151 zoj1295 Word Reversal 字符串的简单处理
Word Reversal 字符串的处理For each list of words, output a line with each word reversed without changing the order of the words.This problem contain原创 2017-08-10 16:30:18 · 253 阅读 · 0 评论 -
ZOJ 2002 Copying Books 二分 贪心
传送门:Zoj2002题目大意:从左到右把一排数字k分,得到最小化最大份,如果有多组解,左边的尽量小。思路:贪心+二分(参考青蛙过河)。方向:从右向左。注意:有可能最小化时不够k分。如 3 3 1 2 3 k分得到最小化的最大是3,却只原创 2017-08-19 15:20:07 · 195 阅读 · 0 评论 -
zoj 2136 Longest Ordered Subsequence 最长上升子序列 新思路
Longest Ordered SubsequenceTime Limit: 2 Seconds Memory Limit:65536 KB A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1原创 2017-08-13 12:18:14 · 219 阅读 · 0 评论 -
ZOJ2006 一道很尴尬的string操作题
ZOJ2006(最小表示法) 题目大意:输出第一个字符串的最小字典序字串的下标!然后我居然想试一试string的erase的能力,暴力一下,然后20msAC了,尴尬的数据。。。。。。。。。。#include#include#include#includeusing namespace std;string s,Min;char temp;int Pos;void _wo原创 2017-08-19 16:18:12 · 186 阅读 · 0 评论 -
zoj 1526 Big Number 数学
Big NumberTime Limit: 10 Seconds Memory Limit:32768 KB In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission原创 2017-08-10 18:05:54 · 274 阅读 · 0 评论 -
zoj1797 Least Common Multiple 最小公倍数
Least Common MultipleTime Limit: 2 Seconds Memory Limit:65536 KB The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by a原创 2017-08-10 17:41:36 · 310 阅读 · 0 评论 -
ZOJ1181 Word Amalgamation 字符串 排序查找
传送门:ZOJ1181 思路:自身排序来判断两个字符串拥有相同的字符。 #include#include#include#include#include#include#include#includeusing namespace std;string dic[110];string sedic[110];string x;string six(6,'X')原创 2017-08-17 14:06:50 · 210 阅读 · 0 评论 -
ZOJ1315
代码先寄放这里#include#include#include#include#include#includeusing namespace std;int n,m,T=0;mapMap;void _update(){ Map.clear();}void _init1(){ string s; for(int i=1;i<=n;i++){ cin>>s;原创 2017-08-17 12:57:45 · 204 阅读 · 0 评论 -
ZOJ1171
错误代码先放这#include#include#include#include#include#includeusing namespace std;mapMap;string s;char C[10000000];int num[100];void _solve(string v){ string t=v; sort(t.begin(),t.end()); num[原创 2017-08-17 12:56:01 · 192 阅读 · 0 评论 -
zoj3211dream city dp 斜率
斜率 DP 优化代码 Dream CityJAVAMAN is visiting Dream City and he sees a yard of gold coin trees. There aren trees in the yard. Let's call them tree 1, tree原创 2017-08-09 16:17:24 · 211 阅读 · 0 评论 -
zoj 3778 Talented Chef
zoj3778题目大意:有n个数,每一次操作你可以最多选择m个数自减一,求直到所有数都为零,的最小操作次数。第一想法肯定是贪心排序:用一个大根堆,每次选前面的min(m,n)个自减一,这样保证了每一次可以选最接近m个数自减一。然后发现超时。规律:1,n不大于m,不必计算。ans=max(ai);1 2, n大于m,前ans-1次操作必然要每次有m个对象,第a原创 2017-08-16 18:49:36 · 181 阅读 · 0 评论 -
zoj3321 circle floyd 最小生成树
Circle 断一个图是否是一个环。 思路:必有m==n,那么我们用n-1条边能够生成一棵树(即是所有点联通,则用floyd即可),然后看最后一条边的两个点是否是单边(度为一)即可 。原创 2017-08-16 18:24:32 · 158 阅读 · 0 评论 -
zoj3204 connect them 最小生成树 暴力
Connect themYou have n computers numbered from 1 ton and you want to connect them to make a small local area network (LAN). All connection原创 2017-08-09 14:12:16 · 166 阅读 · 0 评论 -
zoj 1081 Points Within (判断点是否在多边形内)
http://blog.csdn.net/zxy_snow/article/details/6339621先保存,搞懂了再来写转载 2017-08-16 14:47:49 · 198 阅读 · 0 评论 -
zoj3432 Find the Lost Sock 亦或的运用
只有一个出现奇数次,答案就是它了:#include#include#include#include#includeusing namespace std;char s[10],c;int main(){ int n; while(~scanf("%d\n",&n)){ for(int i=0;i<=7;i++) s[i]='\0'; for(int i=1;原创 2017-08-16 12:01:15 · 195 阅读 · 0 评论