跳到正文

题解

P4727题解

wdsqwq约 2 分钟
原文
文章信息与版本

文章信息

发布
2021年9月8日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 2 分钟
题目
P4727

版本

  1. v1当前

打表经典题。

手算一下:

n123456
ans11241134

oeis 上查一下,表在这里。

这时候输入表,直接高精取余即可。

打表程序:

C++
#include<iostream>
#include<cstring>
using namespace std;
long long check(string a){//对997取余
	long long ans=0;
	for(int i=0;i<a.length();i++){
		ans=(ans*10+a[i]-'0')%997;
	}
	return ans;
} 
int main(){
	freopen("smal.in","r",stdin);//一定要加,不加复制不了表
	freopen("smal.out","w",stdout);
	long long ans;
	int bh;
	string s;
	for(int i=0;i<60;i++){
		cin>>bh>>s;
		ans=check(s);
		cout<<ans<<",";//输出表
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Code:

C++
#include<iostream>
using namespace std;
int a[]={1,1,2,4,11,34,156,47,382,493,291,56,400,993,778,96,890,888,766,749,7,304,785,887,46,799,403,68,742,852,567,582,803,231,122,61,761,151,931,617,870,170,736,521,412,976,217,383,119,447,314,793,952,321,665,663,780,791,78,403,683,219,441,685,367,594,640,523,989,781,210,508,695,637,897,17,788,418,570,794,457,232,738,759,193,494,292};
int main(){
	int n;
	cin>>n;
	cout<<a[n];
	return 0;
}
原文
存档评论2 条抓取于