码迷,mamicode.com
首页 > 其他好文 > 详细

ZOJ 1633

时间:2014-10-22 21:37:24      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   sp   

迭代

每个数对应前面的一个数

bubuko.com,布布扣
#include<stdio.h>
#include<iostream>
using namespace std;
#define max 88
long long s[max], n,p;
char *first="T.T^__^";
void Init()
{
    s[0]=7;
    s[1]=10;
    int i;
    for(i=2; i <= max; i++)
        s[i]=s[i-1]+s[i-2];
}
int getp()
{
    int i=0;
    while(n>s[i])
        i++;
    return i-1;
}
int main()
{
    Init();
    while(scanf("%lld",&n)!=EOF)
    {
        while(n>7)
        {
            p=getp();
            n-=s[p];
        }
        cout<<first[n-1]<<endl;
    }
    return 0;
}
View Code

 

ZOJ 1633

标签:style   blog   http   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/icodefive/p/4044183.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!