HDU 1592 Half of and a Half(大数)】的更多相关文章

将斐波那契的前100000个,每个的前40位都插入到字典树里(其他位数删掉),然后直接查询字典树就行. 此题坑点在于 1.字典树的深度不能太大,事实上,超过40在hdu就会MLE…… 2.若大数加法时,保存的位数过少,就会导致低位误差,累积起来就可能导致前40位产生错误,解决办法是提高精度. #include<iostream> #include<cstring> #include<string> #include<cstdio> using namespa…
Half of and a Half Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1179    Accepted Submission(s): 539 Problem Description Gardon bought many many chocolates from the A Chocolate Market (ACM). W…
[HDU 5351 MZL's Border]题意 定义字符串$f_1=b,f_2=a,f_i=f_{i-1}f_{i-2}$. 对$f_n$的长度为$m$的前缀$s$, 求最大的$k$满足$s[1]=s[m-k+1],s[2]=s[m-k+2]...s[k]=s[m]$ Solution 先列出前几个字符串 $f_3=ab,f_4=aba,f_5=abaab,f_6=abaababa,f_7=abaababaabaab$. 对于n,m. 假设$f_{n-1}$的长度大于等于$m$,那么相当于求…
Problem Description You will be given a string which only contains '1'; You can merge two adjacent '1' to be '2', or leave the '1' there. Surly, you may get many different results. For example, given 1111 , you can get 1111, 121, 112,211,22. Now, you…
Problem Description Determine whether a sequence is a Geometric progression or not. In mathematics, a **geometric progression**, also known , , , , ... . Similarly , , /. Examples of a geometric sequence are powers rk of a fixed number r, such as 2k…
题目链接>>>>>> 题目大意:手动模拟大数加法,从而进行两个大数的加法运算 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; #define MAXN 3000 int a[MAXN], b[MAXN]; int main() { int t; scanf(; getchar(); int array[MAXN]; whi…
Segment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description     Silen August does not like to talk with others.She like to find some interesting problems. Today she finds an interesting problem.She…
题目链接 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.   Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T li…
Game of Taking Stones Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 456    Accepted Submission(s): 174 Problem Description Two people face two piles of stones and make a game. They take turns…
题意:就是求a+b (a,b都不超过1000位) 思路:用数组存储 第一道大数的题目,虽然很水,纪念一下! 代码: #include<cstdio> #include<cstring> int main(){ int t,lena,lenb,i,j,sum,testcase=0; char a[1024],b[1024]; char c[1024];//存 a+b int co;//进位 scanf("%d",&t); int tt=t; while(t…