Educational Codeforces Round 70 (Rated for Div. 2) D. Print a 1337-string...(数学)

题目链接·
在这里插入图片描述

#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int maxn=1e5+1;
const int mod=1e9+7; 
ll dp[maxn],sum[maxn];
int main()
{
	int T;
	for(int i=1;i<maxn;++i)
	sum[i]=i*(i-1)/2;
	scanf("%d",&T);
	while(T--)
	{
		ll n;
		scanf("%lld",&n);
		int i=1;
		for(i=1;i<maxn&&sum[i]<=n;++i) ;
		i--;
		if(sum[i]==n)
		{
			printf("1");
			for(int j=1;j<=i;++j) printf("3");
			printf("7\n");
		}
		else {
			printf("133");
			for(int j=1;j<=n-sum[i];++j) printf("7");
			for(int j=1;j<=i-2;++j) printf("3");
			printf("7\n");
		}
	}
}
发布了328 篇原创文章 · 获赞 1 · 访问量 9079

猜你喜欢

转载自blog.csdn.net/qq_42479630/article/details/105280460