http://acm.hust.edu.cn/vjudge/contest/view.action?cid=30506#problem/T

题意:给你一束光,问你在一个三层的平面类传递n次的种数;

仔细想下,就是一个fibonacci数列;

#include<map>
#include<set>
#include<list>
#include<cmath>
#include<ctime>
#include<deque>
#include<stack>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<sstream>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional> using namespace std ; vector<string> Fibs ;
void CalFibs()
{
const int maxn = 10000 ;
int carry , i , j , size1 , size2 , num1 , num2 ;
string add1 , add2 ;
add1 = '1' ;
add2 = '2' ;
Fibs.push_back( add1 ) ;
Fibs.push_back( add2 ) ;
for( int k = 3 ; k <= maxn ; ++k )
{
string sum ;
carry = 0 ;
i = j = 0 ;
size1 = add1.size() ;
size2 = add2.size() ;
while( i < size1 || j < size2 )
{
if( i < size1 )
{
num1 = add1[ i ] - '0' ;
++i ;
}
else
{
num1 = 0 ;
}
if( j < size2 )
{
num2 = add2[ j ] - '0' ;
++ j ;
}
else
{
num2 = 0 ;
}
num1 += ( num2 + carry ) ;
carry = num1 / 10 ;
num1 %= 10 ;
sum.push_back( num1 + '0' ) ;
}
if( carry )
{
sum.push_back( carry + '0' ) ;
}
Fibs.push_back( sum ) ;
add1 = add2 ;
add2 = sum ;
}
} int main()
{
CalFibs() ;
int n , i ;
string result ;
while( cin >> i )
{
i += 2 ;
result = Fibs[ i - 1 ] ;
for( i = result.size() - 1 ; i >= 0 ; --i )
{
cout << result[ i ] ;
}
cout << endl ;
}
return 0;
}

Ray Through Glasses的更多相关文章

  1. UVA 10334 Ray Through Glasses

    自己手动画了第三项发现f[3]=5;就猜斐波那契了.实际上光线分为两种距离外界有2面玻璃,1面玻璃 其分别时n-1次反射,n-2次反射形成的 故推出斐波那契. 手动一些f1,f2,f3就OK #inc ...

  2. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  3. UvaLA 3938 "Ray, Pass me the dishes!"

                            "Ray, Pass me the dishes!" Time Limit: 3000MS   Memory Limit: Unkn ...

  4. ray与triangle/quad求交二三事

    引擎中,ray与quad求交,算法未细看,但有求解二次方程,不解.ray与triangle求交,使用的是97年经典算法,仔细看过论文,多谢小武同学指点,用到了克拉默法则求解线性方程组.想模仿该方法,做 ...

  5. OpenCascade Ray Tracing Rendering

    OpenCascade Ray Tracing Rendering eryar@163.com 摘要Abstract:OpenCascade6.7.0中引入了光线跟踪算法的实现.使用光线跟踪算法可实现 ...

  6. CF 676B Pyramid of Glasses[模拟]

    B. Pyramid of Glasses time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. 【Unity3d】Ray射线初探-射线的原理及用法

    http://www.xiaobao1993.com/231.html 射线是一个无穷的线,开始于origin并沿着direction方向. 当射线碰到物体后.它就会停止发射. 在屏幕中拉一个CUBE ...

  8. Load Mental Ray in Maya 2015

    In Maya 2015, we usually use mental ray to render our model, some new users may not see the mental r ...

  9. 2013MPD上海6.22 PM 陆宏杰:通往卓越管理的阶梯 & 6.23AM Ray Zhang 产品创新管理的十八般武艺

    MPD2天的内容,参加了5个课程,其中2个是管理的,分别是陆宏杰老师的<通往卓越管理的阶梯>和Ray Zhang大师的<产品创新管理的十八般武艺>.他们2个人都谈到了一个关于招 ...

随机推荐

  1. Java --CountDownLatch简介

    CountDownLatch 1.类介绍 一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待.用给定的计数 初始化 CountDownLatch.由于调用了 coun ...

  2. Hibernate 3中如何获得库表所有字段的名称

    15问:Hibernate 3中如何获得库表所有字段的名称 答:可以使用以下的程序获得. Configuration conf = new Configuration(); conf.configur ...

  3. Java--Http向服务端提交字条串数据

    package com.joye3g.http; import java.io.BufferedReader; import java.io.DataOutputStream; import java ...

  4. Java 螺纹第三版 第三章数据同步 读书笔记

    多线程间共享数据问题 一.Synchronizedkeyword      atomic一词与"原子"无关,它以前被觉得是物质的最小的单元,不能再被拆解成更小的部分.      当 ...

  5. [ACM] hdu 1251 统计难题 (字典树)

    统计难题 Problem Description Ignatius近期遇到一个难题,老师交给他非常多单词(仅仅有小写字母组成,不会有反复的单词出现),如今老师要他统计出以某个字符串为前缀的单词数量(单 ...

  6. Unity UGUI——遮罩效果(Mask)

    Show Mask Graphic

  7. Perl 5 教程

    Perl 5 教程 http://www.cbi.pku.edu.cn/chinese/documents/perl/index.htm

  8. 嵌入式环境:CentOS下添加用户并且让用户获得root权限

    CentOS下添加用户并且让用户获得root权限 http://www.centoscn.com/CentOS/config/2014/0810/3471.html 1.添加用户,首先用adduser ...

  9. 学习笔记之NodeJs基本操作

    nodejs安装见文章:windows下安装node.js及less 运行js文件:node xxx.js 调用http模块,并指定端口为3000,向客户端输出<h1>Node.js< ...

  10. sql: DUAL

    FROM <<Oracle.Database.11g.SQL>> dual is a table that contains a single row. The followi ...