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;
}
- 2017奇葩机器人大盘点:Sophia想生孩子,Atlas后空翻,贝佐斯骑高达
- silverlight:分享一个不错的自定义布局CollectionFlow(可用于制作相册的哦!)
- 无法取得ConnectionSettings的问题
- DataTable,List去重复记录的方法
- Uploadify的一点总结
- 自动驾驶时代,中国移动要以怎样的姿势进入?
- JQuery中文日期控件
- Silverlight中的帧
- 窗口自动弹出浏览器显示广告的问题
- Instagram 开源用于 Python 3的MonkeyType 工具
- 拼凑了几个自定义的Panel(包括FishEyePanel,WrapPanel等几个常用的布局)
- jquery获取父级一级节点的序号
- Docker容器学习梳理--基础知识(2)
- Blend生成的TransformGroup如何引用?
- 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 数组属性和方法
- C++核心准则T.62:将非依赖类模板成员放入非模板基类中
- C++核心准则T.64:使用特化提供类模板的不同实现
- C++核心准则T.68:在模板中使用{}代替()以避免歧义
- C++核心准则T.69:在模板内部,不要进行不受限制的非成员函数调用
- C++核心准则T.80:不要天真地模板化类继承
- 贪心算法求解:王者荣耀购买点券最优策略
- 面试老被问LinkedList源码?(深度剖析)
- 汽水瓶问题(非常interesting)
- 八种方法(实现两个数互换),绝了绝了!
- 当你触摸屏幕时手机都干了什么?你必须知道的Android事件传递
- 栈与队列:来看看栈和队列不为人知的一面
- 栈与队列:我用栈来实现队列怎么样?
- 栈与队列:用队列实现栈还有点别扭
- 短视频源码php,自动查找重复贴图
- 栈与队列:系统中处处都是栈的应用