量子流逝

-----------------------------I Will Fight For My Dream

SGU 123

sgu上居然也有这种题。。。

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<cstring>
#include<iomanip>
using namespace std;

#ifdef _WIN32
#define i64 __int64
#define out64 "%I64d\n"
#define in64 "%I64d"
#else
#define i64 long long
#define out64 "%lld\n"
#define in64 "%lld"
#endif

#define FOR(i,a,b)      for( int i = (a) ; i <= (b) ; i ++)
#define FF(i,a)         for( int i = 0 ; i < (a) ; i ++)
#define FFD(i,a)        for( int i = (a)-1 ; i >= 0 ; i --)
#define S64(a)          scanf(in64,&a)
#define SS(a)           scanf("%d",&a)
#define LL(a)           ((a)<<1)
#define RR(a)           (((a)<<1)+1)
#define SZ(a)           ((int)a.size())
#define PP(n,m,a)       puts("---");FF(i,n){FF(j,m)cout << a[i][j] << ' ';puts("");}
#define pb              push_back
#define CL(Q)           while(!Q.empty())Q.pop()
#define MM(name,what)   memset(name,what,sizeof(name))
#define write           freopen("out.txt","w",stdout)

const int inf = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double oo = 10e9;
const double eps = 10e-10;
const double pi = acos(-1.0);

i64 gcd(i64 _a, i64 _b)
{
if (!_a || !_b)
{
return max(_a, _b);
}
i64 _t;
while (_t = _a % _b)
{
_a = _b;
_b = _t;
}
return _b;
};

i64 ext_gcd (i64 _a, i64 _b, i64 &_x, i64 &_y)
{
if (!_b)
{
_x = 1;
_y = 0;
return _a;
}
i64 _d = ext_gcd (_b, _a % _b, _x, _y);
i64 _t = _x;
_x = _y;
_y = _t - _a / _b * _y;
return _d;
}

i64 invmod (i64 _a, i64 _p)
{
i64 _ans, _y;
ext_gcd (_a, _p, _ans, _y);
_ans < 0 ? _ans += _p : 0;
return _ans;
}

const int maxn = 42;

i64 s[42];
i64 a[42];

void init()
{
a[1]=1;
s[1]=1;
a[2]=1;
s[2]=2;
for(int i=3;i<maxn;i++)
{
a[i]=a[i-1]+a[i-2];
}
for(int i=3;i<maxn;i++)
{
s[i]=s[i-1]+a[i];
}
return ;
}

int main()
{
init();
int n;
cin>>n;
cout<<s[n]<<endl;
return 0;
}


史上最全的SGU题目分类

2014-02-13 23:39:38

SGU AC人数排序 可以用来确定刷题顺序

2014-12-03 13:23:01

SGU 123 The sum（水~）

2016-04-15 10:15:18

sgu 123 The sum

2012-10-31 22:14:20

【扩展欧几里得+解不等式】sgu106The equation

2015-09-10 16:50:32

SGU

2015-05-23 22:51:43

SGU推荐题目分类

2014年05月06日 34KB 下载

sgu题目分类

2013-06-17 18:37:31

SGU - 168 Matrix 简单递推

2017-11-03 13:38:49

SGU 520 Fire in the Country 博弈SG函数(或者YY一下)

2014-09-03 11:44:19