1.Link:

http://poj.org/problem?id=3982

2.Content:

序列
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7057   Accepted: 3182

Description

数列A满足An = An-1 + An-2 + An-3, n >= 3

编写程序,给定A0, A1 和 A2, 计算A99

Input

输入包含多行数据

每行数据包含3个整数A0, A1, A2 (0 <= A0, A1, A2 <= 32767) 
数据以EOF结束

Output

对于输入的每一行输出A99的值

Sample Input

1 1 1

Sample Output

69087442470169316923566147

Source

3.Method:

套用大数相加模板

http://www.cnblogs.com/mobileliker/p/3512632.html

4.Code:

 #include <iostream>
 #include <string>

 using namespace std;

 ;

 string sum(string s1,string s2)
 {
     if(s1.length()<s2.length())
     {
         string temp=s1;
         s1=s2;
         s2=temp;
     }
     int i,j;
     ,j=s2.length()-;i>=;i--,j--)
     {
         s1[i]=?s2[j]-));   //注意细节
         )
         {
             s1[i]=+');
             ]++;
             '+s1;
         }
     }
     return s1;
 }

 int main()
 {
     //freopen("D://input.txt","r",stdin);

     int i;

     string str0,str1,str2,str3;

     while(cin >> str0 >> str1 >> str2)
     {
         //cout << str0 << endl;
         //cout << str1 << endl;
         //cout << str2 << endl;

         i = Num - ;
         while(i--)
         {
             str3 = sum(str0,str1);
             str3 = sum(str3,str2);
             str0 = str1;
             str1 = str2;
             str2 = str3;
         }

         cout << str3 << endl;

     }

     ;
 }

5.Reference:

Poj 3982 序列的更多相关文章

  1. POJ 3982 序列(JAVA,简单,大数)

    题目 //在主类中 main 方法必须是 public static void 的,在 main 中调用非static类时会有警告信息, //可以先建立对象,然后通过对象调用方法: import ja ...

  2. POJ 3982 序列 塔尔苏斯问题解决

    而且还加入了大量的主题,直接或模板Java我们能够在水. 除了循环33它的时间,计算A99它是第几,输出准确回答. #include <stdio.h> #include <stri ...

  3. hdu 2243 考研路茫茫——单词情结 ac自动机+矩阵快速幂

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2243 题意:给定N(1<= N < 6)个长度不超过5的词根,问长度不超过L(L <23 ...

  4. 把一个序列转换成非严格递增序列的最小花费 POJ 3666

    //把一个序列转换成非严格递增序列的最小花费 POJ 3666 //dp[i][j]:把第i个数转成第j小的数,最小花费 #include <iostream> #include < ...

  5. poj 1659 Frogs' Neighborhood (贪心 + 判断度数序列是否可图)

    Frogs' Neighborhood Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 6076   Accepted: 26 ...

  6. POJ 2250 (LCS,经典输出LCS序列 dfs)

    题目链接: http://poj.org/problem?id=2250 Compromise Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  7. POJ 1240 Pre-Post-erous! && East Central North America 2002 (由前序后序遍历序列推出M叉树的种类)

    题目链接:http://poj.org/problem?id=1240 本文链接:http://www.cnblogs.com/Ash-ly/p/5482520.html 题意: 通过一棵二叉树的中序 ...

  8. poj 2828 Buy Tickets 【买票插队找位置 输出最后的位置序列+线段树】

    题目地址:http://poj.org/problem?id=2828 Sample Input 4 0 77 1 51 1 33 2 69 4 0 20523 1 19243 1 3890 0 31 ...

  9. poj 1659 Frogs&#39; Neighborhood 度序列可图化 贪心

    题意: 对一个无向图给出一个度序列,问他是否可简单图化. 分析: 依据Havel定理,直接贪心就可以. 代码: //poj 1659 //sep9 #include <iostream> ...

随机推荐

  1. Codeforces 278C Learning Languages(并查集)

    题意抽象出来就是求联通块的个数吧,然后添加最少边使图联通. 注意所有人都不会任何语言的时候,答案是n而不是n-1. #include<algorithm> #include<iost ...

  2. Github上最全的APICloud开源前端框架效果盘点(转)

    1.微信网站几分钟变身“原生 App” 微信推出了微信JS-SDK,使微信公共号可以直接调用微信原生的接口,具备部分原生应用的能力.微信JS-SDK的推出,将大大提高微信公共号的 用户体验,但是如果存 ...

  3. php实现网页标签补全方法(转)

    导读:PHP在生成静态文件的时候,有时候会因为一些混编问题让HTML标签不完整或混乱而导致页面混乱.作者分享下面这段小代码可以非常方便解决问题. 如果你的网页内容的html标签显示不全,有些表格标签不 ...

  4. MYSQL 5.7 新增150多个新功能

    http://www.thecompletelistoffeatures.com/ There are over 150 new features in MySQL 5.7. The MySQL ma ...

  5. 用Linux安装光盘修复GRUB

    转载:http://lgn21st.iteye.com/blog/179455 需要开视频会议,我不得零时从Ubuntu切换回去百年难道用一次的WinXP...发现自己的XP系统很混乱...决定重新装 ...

  6. 解决ajax回调函数无返回值得问题

    这里以编辑验证角色名为例: 首先,定义一个flag全局变量. 然后,在回调函数resp()中根据判断将flag的值设为true或false. 最后,在调用函数ckrname()中,return fla ...

  7. C#编程实现DNS Client和Server(转)

    我们大多数人使用DNS主要是用于域名解析,近期有个特殊的需求:通过DNS协议传递特殊数据.翻遍互联网,最终找到了一个强大的C# DNS工具库  ARSoft.Tools.Net library ,感谢 ...

  8. 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败/OLE DB 错误: OLE DB 或 ODBC 错误 :

    用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败/OLE DB 错误: OLE DB 或 ODBC 错误 : 2012-2-23 上午 ,弄SAAS时,发现在生成多维数据集 ...

  9. Oracle中exists与in的区别

    有两个简单例子,以说明 "exists"和"in"的效率问题 1) select * from T1 where exists(select 1 from T2 ...

  10. yii2.0根据query查看sql语句

    时间长不用就总是忘记,好记性比不上烂笔头,记录下来备用: Yii::$app->getDb()->getQueryBuilder()->build($query));