
Others
文章平均质量分 65
深蓝色的猫
一个努力成长为大牛的蒟蒻程序媛
展开
-
URAL 1057 Amount of Degrees
#include#includeusing namespace std;int f[35][35],temp[35];void init(){ f[0][0]=1; for(int i=1;i f[i][0]=f[i-1][0]; for(int j=1;j }}int calc(int x,int k){ int tot=0,ans=0;原创 2014-04-27 00:46:48 · 307 阅读 · 0 评论 -
SCU 2014 Training Weekly 1 A、Egypt
1、纯粹考英文阅读理解的。。。判断是否为直角三角形。#include#includeusing namespace std;int main(){ int a[3]; while(scanf("%d%d%d",&a[0],&a[1],&a[2])==3){ if(a[0]==0) break; sort(a,a+3); if(a[0]*a[0原创 2014-03-25 23:58:19 · 187 阅读 · 0 评论 -
CDOJ 793 A Linear Algebra Problem
1、就利用矩阵相乘的公式,注意a[i][j]==0(i!=j),可以大大化简公式,但是不要忘了考虑i==j的情况。具体见代码。#includeusing namespace std;int n,a[1010];bool flag;int main(){ while(scanf("%d",&n)==1){ flag=true; for(int i=原创 2014-04-02 20:04:38 · 334 阅读 · 0 评论 -
2013 ACM/ICPC Asia Regional Online —— Warmup2 A、Computer Graphics Problem
1、#includeusing namespace std;int main(){ int T,x; scanf("%d",&T); for(int i=1;i scanf("%d",&x); x/=10; x=10-x; printf("Case #%d:\n",i); printf("*------------*\n"); for(i原创 2014-05-01 22:10:40 · 273 阅读 · 0 评论 -
2013 ACM/ICPC Asia Regional Online —— Warmup2 E、Naive and Silly Muggles
#include#include#includeusing namespace std;const double PI=acos(-1.0);const double eps=1e-10;struct Point{ double x,y; Point(double x=0,double y=0):x(x),y(y){}};typedef Point Vect原创 2014-05-01 22:22:02 · 338 阅读 · 0 评论 -
2013 ACM/ICPC Asia Regional Online —— Warmup2 K、Kia's Calculation
#include#include#includeusing namespace std;char A[1000010],B[1000010];int num1[10],num2[10];int main(){ int T; scanf("%d",&T); for(int kase=1;kase scanf("%s%s",A,B);原创 2014-05-01 22:27:43 · 471 阅读 · 0 评论 -
HDOJ 4786
1、0不属于Fibonacci数列!程序还真是一点马虎不得。。。2、用Kruskal求最小生成树,分别以不同的优先级取边得到白边的范围,只要有一个fibonacci number落在范围内即输出YES。3、最近开始觉得孤独了。。。真是辛苦。正是因为我选择的路少有人走才会这样吧。。。勇敢些吧!#include#includeusing namespace std;const原创 2014-02-19 19:54:59 · 282 阅读 · 0 评论 -
HDOJ 4788
1、做一道区域赛水题找找自信。。。2、博客好几天没更新了,我知道不应该,但是心里挺难受的。一道题,卡了3天没做出来,这是其一。而且最近项目催得紧,是关于模式识别的,看冈萨雷斯的《数字图像处理》就像看天书一样。我没想到自己的ACM基础一点用场也派不上。自己反而不如那些不搞ACM的。人家才不管怎么实现呢,把别人写好的代码直接拿来用就行了,可是我就是想要把原理搞清楚,弄得进度很慢。。。自我安慰地想,原创 2014-02-19 17:49:05 · 291 阅读 · 0 评论 -
ZOJ 3729 Arnold
1、这道题官方题解是用Baby-Step,Giant-Step,但是我写了三天都失败了,最后经ACdreamer指点,用“求斐波那契数模n的循环节”的方法才做出来的。2、将题目中的坐标用数字代入,可以发现坐标组成了一个斐波那契数列。我们要求的就是斐波那契数列模N的循环节,求出这个循环节后,再除以二,就是本题的答案了。3、代码是我参照ACdreamer博客上的标程,然后自己实现的,欢迎指正。原创 2014-02-23 18:01:25 · 919 阅读 · 0 评论 -
ZOJ 3728 Collision
1、2013年长沙赛区C题,还以为多难呢,原来就是解方程。想想也是,编程不就是将实际问题用数学方法解答么?2、当且仅当和外圆相交得到两个正数的时间时,解才会大于零,否则一律认为不相交,输出0.000,小圆同理。#include#includeusing namespace std;double Rm,R,r,x,y,vx,vy;int main(){ while原创 2014-02-10 17:34:31 · 664 阅读 · 2 评论 -
Google Code Jam 2014 Qualification Round A
1、一个模拟题。。。看代码吧。。。#includeusing namespace std;int a[10][10],b[20][2];int main(){freopen("A--small-attempt1.in","r",stdin);freopen("A--small-attempt1.out","w",stdout); int T,fn,sn;sca原创 2014-04-13 10:10:49 · 466 阅读 · 0 评论 -
Google Code Jam 2014 Qualification Round D
1、题意比较复杂,但理解后就知道用模拟+贪心就能做。原创 2014-04-13 10:12:54 · 337 阅读 · 0 评论 -
Google Code Jam 2014 Qualification Round B
1、用贪心f#include#include#includeusing namespace std;const double eps=1e-9;double dcmp(double x){ if(fabs(x)if(x>0) return 1;return -1;}int main(){ //freopen("B--large.in","r"原创 2014-04-13 10:11:49 · 354 阅读 · 0 评论 -
ZOJ 3736 Pocket Cube
1、本题就是一道隐式图搜索。2、不需要判重,因为可以重复,也不需要规定每次一定要转动,因为不转的话,答案不可能比转动更优。3、把六种旋转情况考虑出来即可。#include#includeusing namespace std;struct cube{ int d[24]; int cnt;};cube c;int f[6][24]={原创 2014-02-23 22:12:14 · 689 阅读 · 1 评论 -
HDOJ 4782
1、这是一道较为繁琐的模拟题,我自己写怎么都写不对,也找不到原因,后来看了别人的题解才写对。2、总的思想是这样的,以字符串为单位,将其压入vector v中,挨个处理,字符串可以是两头都没有尖括号的,也可以是两头都有尖括号的。3、如果是类型,则在输出字符串后,将空格数+1,如果是类型,则空格数减一,再输出字符串,如果是类型,当做普通字符串处理。4、如果是普通字符串,则开头的一个正常输出原创 2014-02-21 23:26:56 · 297 阅读 · 0 评论 -
HDOJ 4802
1、求加权平均数,P和N要被忽略。2、注意不要除零。3、浮点数要判定相等的话不能直接比较,必须看差值的绝对值是否小于一个很小的值。4、注意最后答案保留两位小数。#include#includeusing namespace std;int main(){ //freopen("4802.in","r",stdin); int n,temp,sum;原创 2014-02-22 05:00:55 · 469 阅读 · 0 评论 -
UVa OJ 536
#include#includeusing namespace std;const int MAXN = 30;void build(int n, char* s1, char* s2, char* s) { if(n int p = strchr(s2, s1[0]) - s2; build(p, s1+1, s2, s); build(n-p-1, s原创 2013-09-11 11:47:58 · 270 阅读 · 0 评论 -
UVa OJ 122
#include#include#includeusing namespace std;const int MAXN = 256;typedef struct TNode{ int have_value; int v; struct TNode* left, *right;} Node;Node* root;Node* newnode() {原创 2013-09-03 23:22:31 · 237 阅读 · 0 评论 -
UVa OJ 642
#include#include#includeusing namespace std;int n;char word[2000][10], sorted[2000][10];int cmp_char(const void* _a, const void* _b) { char* a = (char*)_a; char* b = (char*)_b; re原创 2013-09-02 20:06:51 · 281 阅读 · 0 评论 -
UVa OJ 623
1、自从写了这个模板后,高精度变成了我最喜欢的题型之一哈哈~本题是求阶乘,以后千万要注意求阶乘的题目一定要事先保存然后递推,不然会TLE疯了的~#include#include#include#includeusing namespace std;const int maxn=5000;struct bign{ int len,s[maxn]; bi原创 2013-09-02 19:50:23 · 312 阅读 · 0 评论 -
UVa OJ 455
#include #include using namespace std;int main() { int T; scanf("%d", &T); while(T--) { char word[100]; scanf("%s", word); int len = strlen(word); for (int i = 1; i原创 2013-09-02 13:13:39 · 268 阅读 · 0 评论 -
UVa OJ 272
#include using namespace std;int main() { int c, q = 1; while((c= getchar()) != EOF) { if(c == '"') { printf("%s", q ? "``" : "''"); q = !q; } else printf("%c", c); } return原创 2013-09-02 13:00:31 · 263 阅读 · 0 评论 -
UVa OJ 160
#include#includeusing namespace std;int is_prime(int n) { for(int i = 2; i*i if(n % i == 0) return 0; return 1;}int prime[100], count = 0;int main() { int n, p[100]; for(原创 2013-08-29 22:39:15 · 328 阅读 · 0 评论 -
UVa OJ 679
#includeusing namespace std;int main() { int T, D, I; scanf("%d", &T); while(T--) { scanf("%d%d", &D, &I); int k = 1; for(int i = 0; i if(I%2) { k = k*2; I = (I+1)/原创 2013-09-11 12:02:49 · 286 阅读 · 0 评论 -
HDOJ 4790
1、用数形结合的方法做。摘抄某神犇的题解:这题就是要找在[a,b] [c,d] 之间,和模p等于m的对数。把[a,b] [c,d]所有可能组合的和写成下列形式。a+c a+c+1 a+c+2 ..................a+d a+c+1 a+c+2 a+c+3 ........a+d a+d+1原创 2014-02-22 04:28:44 · 297 阅读 · 0 评论 -
ZOJ 3726 Alice's Print Service
1、2013年长沙赛区现场赛A题,就是一个模拟吧。。。唯一一个要注意的就是总花费最多可达到10的18次方,所以INF应为10的18次方加一,数组也要用long long。2、每一次先算出“正常花费”,再算出“灵活花费”(即多加打印数反而花费少),灵活花费也就是保存在Min数组里,用O(n)处理,O(1)查询即可。3、代码并不复杂,看有人用了线段树,完全没有必要嘛。 #include原创 2014-02-05 14:31:46 · 393 阅读 · 0 评论 -
NOIp2013 Training Series #2 Sum of xor
1、通过这道题,我学习了“暴力求解,然后找规律”的方法。正常情况下去分析每一个二进制位自然是可以的,但是暴力法的话会更加直观一些。2、注意printf("%lld\n,1);交到OJ上会出错,所以应该将1作为字符打出来。#include#includeusing namespace std;int main(){ long long n,t; while(scanf("原创 2013-11-13 10:41:28 · 369 阅读 · 0 评论 -
Facebook Hacker Cup Qualification Round(2013)
1、Facebook的黑客杯资格赛,三道题过一道就可以进Round 1了,今天发现我刚好过了第二道,于是顺利晋级!不过我不知道第一道错误的原因是否是因为我采用了标准输入输出(有位参加三年黑客杯的大牛告诉我要用文件输入输出),幸好第二道及时改成了文件输入输出,否则就杯具了。。。嘛,过了就好!2、这里放上官网的题解和我的第二题的程序吧~1. Square Detector (20 Points原创 2013-11-25 16:51:53 · 497 阅读 · 0 评论 -
NOIp2013 Training Series #1 Xor
1、给出无向图G,边(Ai,Bi)的权是Ci,判断下列性质是否成立:对于任意圈C,其边权的异或和是0。2、这道题看了一点思路都没有,首先什么是异或和?去群里问后,发现就是一系列数的异或。接着就是如何判环。数据量很小,明显dfs可以,但我在实现的过程中犯了三个错误:1、由于是无向图,所以必须记录结点的父亲,否则会循环访问,而且父亲必须是局部变量,是dfs的一个参数。2、异或和sum必须是局部变量原创 2013-10-13 15:03:39 · 522 阅读 · 0 评论 -
NOIp2013 Training Series #1 Increasing
1、数列a1到an,修改最少的数字,使数列严格单调递增。2、拿到这道题第一个想法是求最长上升子序列,但是很容易举出反例,1,5,4,2,3明显最长上升子序列是1,2,3,但是知道这个没有什么用,1,2之间没有多余的整数给5和4来修改了。难道要分类讨论?太麻烦了。3、看到贴吧里的讨论,终于有了思路:其实,我们所有的要求就是a[j]-a[i]>=j-i,也就是说,如果两个数相差4,那他们中间最原创 2013-10-13 12:07:34 · 482 阅读 · 0 评论 -
NOIp2013 Training Series #1 Difference
1、数列a1到an,q个询问(L,R),问aL到aR是否互不相同。2、这道题刚拿到就觉得是线段树,但是要维护什么信息?刚开始,我维护了min和max两个信息,但是这只适用于判断aL到aR是否相同,而不能判断是否不同。因为,只要有两个数数值相同,就认为aL到aR是不同的。直到比赛结束,我都没有想出该维护什么信息。后来问了别人,知道应该用一个数组a来保存离第i个数最近的与它数值相同的数的位置j。然原创 2013-10-13 10:47:52 · 418 阅读 · 0 评论 -
HDOJ 4739
1、计算几何,暴力过。。。#include #include#include#includeusing namespace std;struct Point{ int x,y; Point(int x=0,int y=0):x(x),y(y){}};typedef Point Vector;bool operator return原创 2013-09-17 08:39:37 · 330 阅读 · 0 评论 -
UVa OJ 524
#include#include#includeusing namespace std;int is_prime(int x) { for(int i = 2; i*i if(x % i == 0) return 0; return 1;}int n, A[50], isp[50], vis[50];void dfs(int cu原创 2013-09-11 21:36:39 · 279 阅读 · 0 评论 -
UVa OJ 143
#include#include#includeusing namespace std;const int FACTOR = 100;bool left_or_on(int x1, int y1, int x2, int y2) { return x1*y2 - x2*y1 >= 0;}int main() { double x1_, y1_, x2_, y原创 2013-08-29 22:14:22 · 270 阅读 · 0 评论