分块打表50pts???
  • 板块P1662 数7
  • 楼主STUDENT00
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/9/2 19:37
  • 上次更新2023/10/27 12:47:59
查看原帖
分块打表50pts???
658786
STUDENT00楼主2022/9/2 19:37

Code:

#include<bits/stdc++.h>
using namespace std;
int x,k,ans,a[]={0,932,293,567,1298,1090,613,613,208,906,1180,574,366,1226,1109,704,65,65,796,588,111,1331,926,287,561,1292,1084,1084,967,562,1260,197,928,720,243,126,1058,1058,784,53,261,738,855,1260,562,288,894,894,34,151,556,1195,921,190,398,875,992,992,294,20,626,834,1311,91,496,1135,861,861,653,176,176,176,176,176,176,176,176,176,176,176,1239,508,716,1193,1310,378,1017,1017,286,494,971,1088,156,795,521,1127,1335,1335,115,520,1159},b[]={1,1,-1,-1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,-1,1,1,-1,-1,1,-1,-1,1,1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,-1,-1,1,-1,-1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,-1,1};
bool check(int k){
	return k%7==0||k%10==7||k/10%10==7||k/100%10==7||k/1000%10==7||k/10000%10==7||k/100000%10==7||k/1000000%10==7||k/10000000%10==7||k/100000000%10==7||k/1000000000%10==7;
}
int main(){
	scanf("%d",&x);
	ans=a[x/10000000];
	k=b[x/10000000];
	int p=x%10000000,q=x/10000000*10000000;
	for(int i=1;i<=p;i++){
		ans+=k;
		if(ans==0) ans=1337;
		if(ans==1338) ans=1;
		if(check(q+i)) k*=-1;
	}
	printf("%d",ans);
	return 0;
}
2022/9/2 19:37
加载中...