AlgoEmperor @ 2019-06-18 19:43:05
本机5000秒出,在线IDE也是。
但是洛谷10个点瞬间T了。
#include <bits/stdc++.h>
#define MAX 400
using namespace std;
struct Num{
int size,x[MAX];
}d1,d2,d3;
const int MAXB = 1e9;
int N,x=3;
inline void add(Num &a,const Num &b,Num &ans)
{
ans.size = a.size;
for (register int i=1; i<=a.size; i++)
{
ans.x[i] = a.x[i] + b.x[i];
if (ans.x[i] >= MAXB)
{
ans.x[i] -= MAXB;
a.x[i+1]++;
}
}
if (ans.x[ans.size+1]) ans.size++;
x = (x==3) ? 1 : x+1;
}
inline void print(const Num &ans)
{
cout << ans.x[ans.size];
cout << setw(10) << setfill('0');
for (register int i=ans.size-1; i>=1; i--)
cout << ans.x[i];
}
int main()
{
ios::sync_with_stdio(0);
cin >> N; N -= 2;
d1.x[1] = 1; d2.x[1] = 2;
d1.size = d2.size = 1;
while (N--){
if (x == 1) add(d2,d1,d3);
if (x == 2) add(d3,d2,d1);
if (x == 3) add(d1,d3,d2);
}
if (x == 1) print(d2);
if (x == 2) print(d3);
if (x == 3) print(d1);
}
by Ynoi @ 2019-06-18 19:45:23
@Ofnoname 5000秒 出当然TLE了(
by Ynoi @ 2019-06-18 19:45:44
@Ofnoname 另外你数组开小了
by Ynoi @ 2019-06-18 19:47:11
sorry 看错了,那是高精的数组
by TNoName @ 2019-06-18 19:48:21
5000秒出当然T啊
by AlgoEmperor @ 2019-06-18 19:49:05
那是输5000秒出,开400是压了位刚好
by Ynoi @ 2019-06-18 19:49:47
@Ofnoname
编译信息提示
“ 警告:在有返回值的函数中未发现 return 语句”
加上试试?
一般没返回值的时候珂能会出奇奇怪怪的问题
by longlongzhu123 @ 2019-06-18 19:57:52
5000秒可还行(滑稽)
by 蒟蒻365 @ 2019-06-18 20:08:49
第一是啥
by WatchmanIce @ 2019-06-18 20:13:33
5000秒可还行(滑稽)
by 4SunnyH @ 2019-06-18 20:18:14
你写了什么代码要跑1.5h