- 博客(49)
- 收藏
- 关注
原创 [总结]对于debug的几点体会
难题的难点通常在于出样例,只要本地能跑出正确结果而且算法合乎逻辑,那么基本上是不需要debug的,但是看起来比较简单的提通常会出现过了样例但是过不了题的情况,这时候debug的能力就是至关重要,就我目前遇到的一些情况总结一下,顺便整理一下思路:1。数论题没开longlong的,这个遇到的次数也是比较多了,结论就是数论题不用多想,直接开longlong,因为涉及到取模的运算在运算中几乎必爆int
2015-04-07 22:01:52
755
原创 POJ 3713 Transferring Sylla(图的三联通,tarjan算法
http://www.hankcs.com/program/algorithm/poj-3713-transferring-sylla.html思路和解答可以参考上面这一篇文章,很详细。这个题一开始tle了若干发,结果把临接矩阵换成临接表a了。。。。。。本来图论题有时候就会出现卡常熟的情况,如果不是需要删边删点什么的临接矩阵还是慎用。。。。。。。#include#include#inc
2015-04-01 19:54:38
1101
原创 HDU4869:Turn the pokers[错误分析
此题是我第一次写数论题(费马小定理),不过这个题的难点不在这里,而是在上下限的推导上。已经有文章写的很清楚了,我就不写这个了。我的错误出在有一个三项连乘的式子没有每一次乘法都取模,结果溢出了,wa了不知道多少次才发现这个问题(毕竟long,long溢出的问题还是没怎么注意过,但是数论题必须要注意这个问题)
2015-03-20 22:47:21
477
原创 POJ2115-C Looooops (错误分析)
这题写WA了多次,主要有两个原因:1.使用位运算的时候没有加LL导致溢出(题目正好给的是k=32)2.最后求解最小x的时候取模,不需要把mod再变回原来的值,因为此时x的值是在mod值变动之后求得的最小值,直接取mod就可以了ll exgcd(ll a,ll b,ll &x,ll &y){ if(b==0){ x=1,y=0; return a; } else{ ll gcd=e
2015-03-15 10:29:11
467
原创 POJ-1061 青蛙的约会
贴代码:ll exgcd(ll a,ll b,ll &x,ll &y){ if(b==0){ x=1,y=0; return a; } else{ ll gcd=exgcd(b,a%b,y,x); y-=(a/b)*x; return gcd; }}int main(){#ifdef LOCAL freopen("in.txt","r",stdin);
2015-03-15 00:17:27
402
原创 不定数目的单行数字读取
本来也是挺基础的东西,原来嫌麻烦一直没写过,今天碰到一道题,正好熟悉一下读取方法;1.使用getline(cin,str)函数读取单行字符串2.用find和substr组合读取分割的数字字符串;3.用c_str()函数将string转换为c字符串,然后用atoi转换为int如果输入为其他类型的数字,比如小数,也有相应的c函数可以调用以下为例vector p;stri
2015-03-13 21:18:11
425
原创 hdoj1007(最近距离点对)Quoit Design
#include#include#include#include#include#include#include#define REP(n) for(int R=0;R<(n);R++)typedef long long i64;#define MX 100005using namespace std;typedef pair P;////(x,y)P A[MX];int
2015-02-21 22:50:54
443
原创 CodeForces 508D(Codeforces Round #288 (Div. 2))Tanya and Password
题本身不是很难,欧拉路径是想到了,但是第一次写总是不太顺利,写完之后还tle了一次,主要是用vector做邻接表无法高效删除边,之后改成list,,AC速度还比其他邻接矩阵快很多#include#include#include#include#include#include#include#define FOR(s,n) for(int i=(s);i<(n);i++)#def
2015-02-09 11:32:24
583
原创 Codeforces Round #287 (Div. 2) 507 E. Breaking Good
写的感觉比以前进步许多,就是遍历邻接表的时候感觉是不是要用堆优化一下,第一次交超时了,郁闷了一阵,突然发现忘了把本地测试的#define删掉了,又试了一次就AC了,这题其实就是个BFS,多维护了一个需要修的路的条数,算法上没什么难度#include#include#include#include#include#include#include#include#include#in
2015-01-28 00:02:20
429
原创 [CF]287div2 C. Guess Your Way Out!
本来感觉这题的递归写的挺完美的,结果test9就是过不去,看来看去没看出原因,就直接看数据了(要不是CF能看数据可能我坑死也找不出原因来),看了数据就很明了了——大数据过不去,但是明明用了longlong'的啊,,,,原来位移(1上代码: #includetypedef long long i64;using namespace std;i64 h,n;i64
2015-01-25 23:20:21
445
原创 uva 10132 File Fragmentation
题目就不抄了,这题很水,确实很水,我他妈WA了4,5次,首先一个没看懂"any of the possible solutions may be output"是个啥意思,以为要输出所有解,搞去重搞了半天还加了个set,然后没看见输出之间要加空行,黑体居然被我无视了-_-||,这个题其实只需要排个序然后枚举所有与最后一个长度相同的串与第一个串的组合即可,纯粹暴力#include#inc
2014-12-01 13:16:01
445
原创 UVA 11205
第一次做到这么暴力的题,我看题的时候被吓到了。。。除了枚举想不出别的算法了,但是枚举好像效率很低,但是算一算就知道15个灯泡有2^15种组合方式,枚举量也就3W左右,每次需要判断100+99+……+1次,数量级是10^3,总的算下来一次数据是10^7,这样的效率应该也够了,看了下别人的写法也是直接暴力。。。。代码附上#include#include#includeusing nam
2014-11-27 17:54:40
489
原创 POJ 3669 Meteor Shower 《挑战程序设计竞赛(第2版)》练习题
Meteor ShowerTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9193 Accepted: 2601DescriptionBessie hears that an extraordinary meteor shower is coming;
2014-11-20 14:32:33
630
原创 11111 - Generalized Matrioshkas
#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long
2014-10-18 22:25:40
407
转载 10790 - How Many Points of Intersection?
How Many Points of Intersection? We have two rows. There are a dots on the top row and b dots on the bottom row. We draw line segments connecting every dot on the top row with every dot on t
2014-10-17 20:07:47
403
原创 107 - The Cat in the Hat
The Cat in the Hat Background(An homage to Theodore Seuss Geisel)The Cat in the Hat is a nasty creature,But the striped hat he is wearing has a rather nifty feature.With one flic
2014-10-16 13:09:35
640
原创 HDU 1443 Joseph
#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;typedef vector vi;typedef set si;int stor[20]={0};int main(
2014-09-04 15:27:20
560
转载 acm steps (Fibonacci)
FibonacciTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2801 Accepted Submission(s): 1308 Problem Description2
2014-09-01 22:45:24
796
原创 acm steps(小数化分数2)
小数化分数2Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2597 Accepted Submission(s): 923 Problem DescriptionRay 在
2014-09-01 16:24:20
652
原创 acm steps(Leftmost Digit)
Leftmost DigitTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2483 Accepted Submission(s): 1088 Problem Descripti
2014-08-31 20:37:29
463
原创 acm steps2.1.5(整数对)
整数对Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2367 Accepted Submission(s): 927 Problem DescriptionGardon和小
2014-08-31 17:13:50
638
原创 acm steps2.1.6(The area)
The areaTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1260 Accepted Submission(s): 1009 Problem DescriptionIg
2014-08-29 23:23:08
540
原创 acm steps 2.1 4(又见GCD)
又见GCDTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2490 Accepted Submission(s): 1230 Problem D
2014-08-29 15:34:02
502
原创 acm steps 2.1.3
Largest prime factorTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4525 Accepted Submission(s): 1360
2014-08-28 18:23:52
645
原创 A. Appleman and Toastman(codeforces#263div1)
A. Appleman and Toastmantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAppleman and Toastman play a game. Initially
2014-08-27 18:48:30
827
原创 acm steps 2.1.2(How many prime numbers)
How many prime numbersTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7775 Accepted Submission(s): 2506 Problem D
2014-08-26 23:07:48
727
原创 acm steps 1.3.7(排列2)
排列2Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2881 Accepted Submission(s): 876 Problem DescriptionRay又对数字的
2014-08-26 21:36:34
743
原创 acm steps1.3.5(排序)
排序Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3929 Accepted Submission(s): 1127 Problem Description输入一行数字,如
2014-08-21 17:10:23
436
原创 hdoj 1.3.3(shǎ崽 OrOrOrOrz)
shǎ崽 OrOrOrOrzTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3859 Accepted Submission(s): 1195
2014-08-20 15:48:25
456
原创 acm steps 1.3.2(百步穿杨)
百步穿杨Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3719 Accepted Submission(s): 1265 Problem Description时维九月,序
2014-08-19 17:02:47
520
原创 acm steps 1.3.1(今年暑假不AC)
代码#include#include#include#include#include#includeusing namespace std;struct event{ int bet; int ent;};bool com(event a,event b){ return (a.ent}int main()
2014-08-19 16:35:54
427
原创 acm steps1.2.8(Identity Card)
Problem DescriptionDo you own an ID card?You must have a identity card number in your family's Household Register. From the ID card you can get specific personal information of everyone. The numbe
2014-08-19 15:09:57
983
原创 acm steps 1.2.7(Specialized Four-Digit Numbers)
#include#include#include#include#include#include#includeusing namespace std;int get10(int n){ int sum=0; while(n>0) { sum+=n%10; n=n/10; }
2014-08-18 16:58:19
747
原创 acm steps 1.2.6(Lowest Bit)
#include#include#include#include#include#includeusing namespace std;int main(){ int x,rem,divs,tial; int cont=0; while(cin>>x&&x!=0) { rem=2; divs
2014-08-18 16:42:54
426
原创 hdoj acm steps1.2.5(IBM Minus One)
#include#include#include#include#includeusing namespace std;int main(){ char str[60]; int n,length,t=0; cin>>n; while(n>0) { n--;t++; cin>>str;
2014-08-18 15:42:09
568
原创 关于c++pow()函数
今天用c++的pow()函数发现了一个问题:如果直接已pow(int,int)的方式来用的话会有误差,当然因为函数的参数应该是(double,double),但是把前一个参数改成double后误差就没了(至少比较小),但是如果同时把后面的参数也改成doubt的话误差又会出现,这是什么情况?
2014-08-15 22:47:39
6493
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人