Educational Codeforces Round 81 (Rated for Div. 2) A. Display The Number
Display The Number
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You have a large electronic screen which can display up to 998244353998244353 decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of 77 segments which can be turned on and off to compose different digits. The following picture describes how you can display all 1010 decimal digits:
As you can see, different digits may require different number of segments to be turned on. For example, if you want to display 11, you have to turn on 22 segments of the screen, and if you want to display 88, all 77 segments of some place to display a digit should be turned on.
You want to display a really large integer on the screen. Unfortunately, the screen is bugged: no more than nn segments can be turned on simultaneously. So now you wonder what is the greatest integer that can be displayed by turning on no more than nn segments.
Your program should be able to process tt different test cases.
Input
The first line contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases in the input.
Then the test cases follow, each of them is represented by a separate line containing one integer nn (2≤n≤1052≤n≤105) — the maximum number of segments that can be turned on in the corresponding testcase.
It is guaranteed that the sum of nn over all test cases in the input does not exceed 105105.
Output
For each test case, print the greatest integer that can be displayed by turning on no more than nn segments of the screen. Note that the answer may not fit in the standard 3232-bit or 6464-bit integral data type.
Example
input
2
3
4
output
7
11
A题笔者可是想了十分钟,太菜了的原因吧,我们观察可得1的成本是2,7的成本是3,其他的都比这两个数高,所以但凡我有2我就多一位,这肯定是最优解,但是如果我只剩下3,我一定取7,其实这里就可以想象最优解一定是形如1111111,或者111117之类的,对吗,不对,因为7111111好像更优,所以应该是偶数就是都1,%3=0的数就首位为7,笔者的代码写的麻烦了,不过是同一个意思~
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rg register ll
ll a[15]={6,2,5,5,4,5,6,3,7,6};
int main()
{
ll t;
cin>>t;
for(rg i=1;i<=t;i++)
{
ll x,ans=0;
cin>>x;
string s;
for(rg j=1;j<=x/2-1;j++)s+='1';
ll tep=x-(x/2-1)*2,maxx=0;
for(rg j=0;j<=9;j++)
{
if(tep>=a[j])maxx=max(maxx,j);
}
s+=maxx+48;
string tepp=s;
reverse(s.begin(),s.end());
if(tepp<s)cout<<s<<endl;
else cout<<tepp<<endl;
}
while(1)getchar();
return 0;
}
- phalapi-进阶篇2(DI依赖注入和单例模式)
- 基于PhalApi的DB集群拓展 V0.1bate
- phalapi-进阶篇1(Api,Domain,和Model)
- 你不知道的Javascript:有趣的setTimeout
- phalapi-入门篇5(数据库操作和Model层)
- HTML5.2新特性解读
- phalapi-入门篇6(小技巧和浅谈API适用范围以及入门篇总结)
- phalapi-入门篇2(把它玩起来)
- phalapi-入门篇3(请求和返回)
- phalapi-入门篇1(简单介绍以及环境搭建)
- 1.开发规范-- 常用的版本控制
- phalcon-入门篇1(基本介绍与环境搭建)
- 基于PhalApi的Redis拓展
- PhalApi-Image -- 图像处理
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- r语言多均线股票价格量化策略回测
- .Net微服务实战之CI/CD
- MySQL发号问题的分析和改进
- 放弃dagger?Anrdoi依赖注入框架koin
- WPF开发之C#中关闭进程的方式
- R语言实现:混合正态分布EM最大期望估计法
- MongoDB 指令
- 硬件设计之 Distributed Arithmetic 一例
- JavaScript 框架学习(JQuery)
- MongoDB 部署
- 结构体对齐原则在自定义协议解析时的妙用之法
- Spring JDBC 框架一个最简单的Hello World级别的例子
- Celery 分布式框架 学习
- .NET Core + K8S + Loki 玩转日志聚合
- varint是啥你真的知道么?