您的位置:首页 > 编程语言 > Go语言

FOJ有奖月赛-2015年11月 Problem A 据说题目很水

2015-11-16 18:11 323 查看
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2205

题        意:给你 n个点,任意两个点由不超过一条边直接相连,而且没有点的边连向自身且不能有任意三个点能够相互连通,而且所有的边数目最多,

思        路:找规律

代码如下:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
using namespac
c74d
e std;
typedef __int64 LL;

int ans[1003];

int main()
{
int T;
ans[0] = 0;
ans[1] = 0;
ans[2] = 1;
ans[3] = 2;
ans[4] = 4;
for( int i = 5; i < 1002; i ++ )
{
ans[i] = ans[i-1] + ans[i-2];
cout<<i<<" "<<ans[i]<<endl;
}
scanf ( "%d", &T );
while( T-- )
{
int n;
scanf( "%d", &n );
printf( "%d\n", ans
);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  algorithm