CY_

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

04 2014 档案

摘要:// 继续大数,哎、、Problem DescriptionA Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)Your task is to take a number as input, and print that Fibon 阅读全文
posted @ 2014-04-30 20:56 CY_ 阅读(150) 评论(0) 推荐(0)

摘要://深刻认识到自己的粗心,为此浪费了一天。。Problem Description话说,经过了漫长的一个多月,小明已经成长了许多,所以他改了一个名字叫“大明”。这时他已经不是那个只会做100以内加法的那个“小明”了,现在他甚至会任意长度的正小数的加法。现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。Input本题目包含多组测试数据,请处理到文件结束。每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。Output请在一行里面输出输出A+B的值,请输出最简形式。详细要求请见Sample Output。Sample Input1.1 2.91.1111111111 2 阅读全文
posted @ 2014-04-30 15:22 CY_ 阅读(261) 评论(0) 推荐(0)

摘要:卡在hdu 1402 的高精度乘法了,要用FFT(快速傅里叶变换),然后看到了这个霍纳法则,顺便就写下来了。霍纳法则:求多项式值的一个快速算法。简单介绍:假设有n+2个数 , a0,a1,a2,a3,……an 和x组成的一个多项式,形式如下: a0*x^0+a1*x^1+a2*x^2+a3*x^3+……an*x^n ,通常都是一项一项的求和然后累加,这样的话要进行n* (n+1)/2 次乘法运算 和 n 次加法运算 ,而霍纳法则就是一个改进的一个算法。通过变换得到如下式子:(((……(((an+an-1)*x+an-2)*x+an-3)*x)+……)*x+a1)*x+a0 ,这种求值的方法便. 阅读全文
posted @ 2014-04-29 10:51 CY_ 阅读(1196) 评论(0) 推荐(0)

摘要:Problem DescriptionFibonacci数列,定义如下:f(1)=f(2)=1f(n)=f(n-1)+f(n-2) n>=3。计算第n项Fibonacci数值。Input输入第一行为一个整数N,接下来N行为整数Pi(1#includeusing namespace std;string add(string x,string y){ string ans ; int lenx = x.length(); int leny = y.length(); if(lenx=0;i--) { temp = x[i] - '0' + y[i] -... 阅读全文
posted @ 2014-04-28 16:33 CY_ 阅读(486) 评论(0) 推荐(0)

摘要:转自博客园:http://www.cnblogs.com/xFreedom/archive/2011/05/16/2048037.html相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用。但是如果离开了MFC框架,还有没有这样使用起来非常方便的类呢?答案是肯定的。也许有人会说,即使不用MFC框架,也可以想办法使用MFC中的API,具体的操作方法在本文最后给出操作方法。其实,可能很多人很可能会忽略掉标准C++中string类的使用。标准C++中提供的string类得功能也是非常强大的,一般都能满足我们开发项目时使用。 阅读全文
posted @ 2014-04-28 16:03 CY_ 阅读(238) 评论(0) 推荐(0)

摘要:Problem DescriptionOneof the first users of BIT's new supercomputer was Chip Diller. He extended hisexploration of powers of 3 to go from 0 to 333 and he explored taking varioussums of those numbers.``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were hereto see the 阅读全文
posted @ 2014-04-28 15:54 CY_ 阅读(281) 评论(0) 推荐(0)

摘要:题目描述Cainiao is a university student who loves ACM contest very much. It is a festival for him once when he attends ACM Asia Regional Contest because he always can find some famous ACMers there.Cainiao attended Asia Regional Contest Fuzhou Site on November 20, 2011. After he got seat map, he wanted t 阅读全文
posted @ 2014-04-28 09:46 CY_ 阅读(174) 评论(0) 推荐(0)

摘要:今天回到宿舍以后,宿舍就剩自己了,然后就胡思乱想了。。 虽然最近一直在各个OJ上做题,但是感觉进步很少,ACM需要的知识太多了,自己会的就太少了,突然就丧失信心了。。然后找了一个小伙伴聊天,他的一句话让我稍微清醒了点,他说的是车到山前必有路!!我总是想的太多,把事情想得太复杂,所以我总是会迷惑。。其实,我不需要想那么多的,我只要根据自己的计划一步一步来就行了。。未来的事情无法预测,只要现在做好了,我想未来肯定也不会差。。我不知道别人是看待自己的ACM之路的,,我觉得自己的ACM是一个学习的过程,在OJ上A题的过程中,对一个知识,我从不会到查资料,到A题,完全熟悉知识点的过程,我觉得这个过程.. 阅读全文
posted @ 2014-04-27 22:33 CY_ 阅读(97) 评论(0) 推荐(0)

摘要:Time Limit: 5000MS Memory limit: 65536K题目描述Haveyou ever played a popular game named "Fruit Ninja"?Fruit Ninja (known as Fruit Ninja HD on the iPad and Fruit Ninja THD for NvidiaTegra 2 based Android devices) is a video game developed by Halfbrick. It wasreleased April 21, 2010 for iPod Tou 阅读全文
posted @ 2014-04-27 18:43 CY_ 阅读(190) 评论(0) 推荐(0)

摘要:Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。我们把这两只青蛙分别叫做青蛙A和青蛙B,并且规定纬度线上东经0度处为原点,由东往西为正方向,单位长度1米,这样我 阅读全文
posted @ 2014-04-26 15:26 CY_ 阅读(353) 评论(0) 推荐(0)

摘要:Description定义An为1,2,…,n的最小公倍数,例如,A1= 1,A2= 2,A3= 6,A4= 12,A5= 60,A6= 60。请你判断对于给出的任意整数n,An是否等于An – 1。Input本题有多组测试数据,输入的第一行是一个整数T代表着测试数据的数量,接下来是T组测试数据。对于每组测试数据:第1行包含一个整数n(2 ≤n≤ 106)。Output对于每组测试数据:第1行如果An等于An-1则输出YES否则输出NO。Sample Input16Sample OutputYES/***********************突然认识到基础不扎实,练习一下打基础,数论欧几里得 阅读全文
posted @ 2014-04-26 14:06 CY_ 阅读(179) 评论(0) 推荐(0)

摘要:Problem Description新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数,否则都是新朋友,现在会长想知道究竟有几个新朋友?请你编程序帮会长计算出来。Input第一行是测试数据的组数CN(Case number,1using namespace std;int Euler(int x)// 求 欧拉函数值 其实就是通式的应用{ int i,res = x; for(i = 2;i*i1) res = res / x*(x-1);// x ... 阅读全文
posted @ 2014-04-25 18:57 CY_ 阅读(150) 评论(0) 推荐(0)

摘要:Binomial CoeffcientsTimeLimit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述输入输出示例输入31 110 2954 723示例输出1453557658/*******************组合数学组合数 用 递推 :组合数公式 C[n][m] =C[n-1][m-1] +C[n-1][m]************************/Code:#include #includeusing namespace std;const int mod = 10000003;const int N = 1005;int C[N][ 阅读全文
posted @ 2014-04-21 21:11 CY_ 阅读(180) 评论(0) 推荐(0)

摘要:Crack MathmenTimeLimit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述Since mathmen take security very seriously, theycommunicate in encryptedmessages. They cipher their texts in this way: for everycharacther c in themessage, they replace c with f(c) = (the ASCII code ofc)n mod 1997if f(c) #include #incl 阅读全文
posted @ 2014-04-21 20:57 CY_ 阅读(182) 评论(0) 推荐(0)

摘要:学习数据结构了,写下来,加深记忆。第一篇://system("cls"); 控制台屏幕刷新#include#include#include#define MAXSIZE 100typedef int DataType;typedef struct{ DataType data[MAXSIZE]; int length;}SeqList;//初始化顺序表SeqList SeqListInit( ){ SeqList L; //coutL.length-1) return -1;// 超出表范围,错误,返回-1 return L.data[i-1];//顺序表元素下标从0开始} 阅读全文
posted @ 2014-04-18 20:52 CY_ 阅读(205) 评论(0) 推荐(0)

摘要:Problem DescriptionConsidera positive integer X,and let S be the sum of all positive integer divisors of2004^X. Your job is to determine S modulo 29 (the rest of the division of S by29).Take X = 1 for an example. The positive integer divisors of 2004^1 are 1, 2, 3,4, 6, 12, 167, 334, 501, 668, 1002 阅读全文
posted @ 2014-04-18 19:56 CY_ 阅读(184) 评论(0) 推荐(0)

摘要:题目描述We know thatif a phone number A is another phone number B’s prefix, B is not able to becalled. For an example, A is 123 while B is 12345, after pressing 123, we callA, and not able to call B.Given N phone numbers, your task is to find whether there exits two numbers Aand B that A is B’sprefix.输入 阅读全文
posted @ 2014-04-14 18:42 CY_ 阅读(206) 评论(0) 推荐(0)

摘要:题目描述We know thatIvan gives Saya three problems to solve (Problem F), and this is the firstproblem.“We need a programmer to help us for some projects. If you show us that youor one of your friends is able to program, you can pass the first hurdle.I will give you a problem to solve. Since this is the 阅读全文
posted @ 2014-04-13 17:34 CY_ 阅读(232) 评论(0) 推荐(0)

摘要:Problem Description要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973)= 1)。Input数据的第一行是一个T,表示有T组数据。每组数据有两个数n(0 A = B*x;n = A % 9973 = A - A / 9973 * 9973 := B*x - A/9973*9973= n可以 令 y = A / 9973; 则 B * x + y * 9973 = n; 因为 gcd(9973,B) = 1,所以不能用exgcd(B,9973,x,y);B * x1 + 9973 * y1 = 1; -.. 阅读全文
posted @ 2014-04-11 15:41 CY_ 阅读(137) 评论(0) 推荐(0)

摘要:Problem Description我知道部分同学最近在看中国剩余定理,就这个定理本身,还是比较简单的:假设m1,m2,…,mk两两互素,则下面同余方程组:x≡a1(mod m1)x≡a2(mod m2)…x≡ak(mod mk)在0#includeusing namespace std;__int64 gcd(__int64 a,__int64 b)//求最大公约数{ __int64 temp; if(a>n>>a&&n&&a) { //memset(a,0,sizeof(a)); ans = 1; cin>>x; ... 阅读全文
posted @ 2014-04-11 13:23 CY_ 阅读(168) 评论(0) 推荐(0)

摘要:Problem DescriptionThe least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105.InputInput will consist of multiple problem instances. The first line of the input will conta 阅读全文
posted @ 2014-04-09 19:38 CY_ 阅读(132) 评论(0) 推荐(0)

摘要:虽然已经学了一年多了,但是看到《程序员的数学》第二章后感想又有很多,就写个读后 小感吧!1.带条件的逻辑与(&&)逻辑与(&&)定义 : (表格形式)可以看出:1). A 为 true 时 , B 的值就为 A && B 的值。2). A 为 false 时,不用看 B ,A && B 的值为 false 。3). A 为 undefined 时,计算机不进行任何处理,因此不用 看 A 和 B ,A && B 的值 为 undefined。代码解释:代码块1if(A && B){ ……}代码块 2i 阅读全文
posted @ 2014-04-07 20:56 CY_ 阅读(272) 评论(0) 推荐(0)

摘要:Problem DescriptionInmany applications very large integers numbers are required. Some of theseapplications are using keys for secure transmission of data, encryption, etc.In this problem you are given a number, you have to determine the number ofdigits in the factorial of the number.InputInputconsis 阅读全文
posted @ 2014-04-04 20:59 CY_ 阅读(154) 评论(0) 推荐(0)