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. android intent收集转载汇总

    Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);                 ComponentName comp = ...

  2. 【Apache ZooKeeper】理解ZooKeeper中的ZNodes

    理解ZooKeeper中的ZNodes 翻译自:http://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html ZooKeeper中的 ...

  3. java.lang.NoClassDefFoundError: org/apache/lucene/analysis/synonym/SynonymFilter

    2013-6-24 13:28:51 org.apache.solr.common.SolrException log 严重: java.lang.NoClassDefFoundError: org/ ...

  4. 异常:未能载入文件或程序集”DAL”或它的某一个依赖项——解决的方法

    以下是我再使用抽象工厂+反射重构机房时,在Factoy中出现了以下一个问题: 去网上查了一下资料,发现这是一个非常普遍的问题,它出现的原因主要有两种: 第一种: 载入DLL路径错误.解决的方法是调整D ...

  5. 总线接口与计算机通信(五)CAN总线

        CAN网络图示     CAN的特点      CAN协议具有以下特点.      (1) 多主控制  在总线空闲时,所有的单元都可开始发送消息(多主控制). 最先访问总线的单元可获得发送权( ...

  6. 技术不牛如何才拿到国内IT巨头的Offer(转)

    不久前,byvoid面阿里星计划的面试结果截图泄漏,引起无数IT屌丝的羡慕敬仰.看看这些牛人,NOI金牌,开源社区名人,三年级开始写Basic...在跪拜之余我们不禁要想,和这些牛人比,作为绝大部分技 ...

  7. 什么是透明(和Windows主题有关系),研究TLable和TPanel是两个好例子

    在controls.pas单元里只有判断,没有赋值,所以一直不是很明白.于是在stdCtrls.pas里找了几个例子,直观加深一下印象: constructor TCustomLabel.Create ...

  8. xss 跨站脚本攻击

    这是一个非常简单的攻击. 两个页面如下: <form action="MyJsp.jsp" method="get"> <input type ...

  9. hdu1200(来来回回串起来)

    Problem Description Mo and Larry have devised a way of encrypting messages. They first decide secret ...

  10. UML建模技术(资料汇总)

    其实,我是非常不喜欢,<深入浅出XXX>.<初级入门XXX>,<21天学会XXX>. ... .and so on , 之类的东西的. 好吧,只是得承认,有些还是不 ...