/ Randle /

记录详情

Runtime Error

foo.cc: In member function 'void sb::add(sb, sb)':
foo.cc:19:8: warning: statement has no effect [-Wunused-value]
    a[i]%10;
    ~~~~^~~
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Wrong Answer Read 43089, expect 89. 15ms 20.164 MiB
#2 Wrong Answer Read 2271911096560726..., expect 365010934. 15ms 20.164 MiB
#3 Wrong Answer Read 5422921697894344..., expect 107579939. 23ms 21.23 MiB
#4 Runtime Error Segmentation fault 83ms 48.727 MiB
#5 Runtime Error Segmentation fault 82ms 48.75 MiB
#6 Runtime Error Segmentation fault 83ms 48.715 MiB
#7 Runtime Error Segmentation fault 83ms 48.715 MiB
#8 Runtime Error Segmentation fault 83ms 48.758 MiB
#9 Runtime Error Segmentation fault 83ms 48.781 MiB
#10 Runtime Error Segmentation fault 83ms 48.699 MiB

代码

#include<bits/stdc++.h>
using namespace std;
struct sb{
	int a[5005],len=1;
	void init(int x)
	{
		a[1]=x;len=1;
	}
	void add(sb x,sb y)
	{
		len=max(x.len,y.len);
		for(int i=1;i<=len;i++)
		{
			a[i]=x.a[i]+y.a[i];
		}
		for(int i=1;i<=len;i++)
		{
			a[i+1]+=a[i]/10;
			a[i]%10;
		}
		if(a[len+1]>0)
		{
			len++;
		}
	}
	void print()
	{
		for(int i=len;i>=1;i--)
		{
			cout<<a[i];
		}
	}
	
}f[5005];
int main()
{
	int n;
	cin>>n;
	f[1].init(1);
	f[2].init(2);
	for(int i=3;i<=n;i++)
	{
		f[i].add(f[i-1],f[i-2]);
	}
	f[n].print();
	return 0;
}

信息

递交者
类型
递交
题目
上楼梯(数据原创)
题目数据
下载
语言
C++
递交时间
2021-11-07 13:44:35
评测时间
2021-11-07 13:44:35
评测机
分数
0
总耗时
637ms
峰值内存
48.781 MiB