Codeforces Round 81 (Rated for Div. 2) A Display The Number

廉价感情. 提交于 2020-01-31 04:45:21
             A  Display The Number

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.InputThe 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.OutputFor 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.

输入

2
3
4

输出

7
11

思路:水题一道,输出1需要2个,输出7需要3个,n是奇数的话输出一个7,剩下的都输出1,n是偶数的话只输出1。

#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
const int mod = 1e8 + 7;
const int MAXN = 1e6 + 10;
const int INF = 0x3f3f3f3f;
int main()
{
 int t,n;
 cin>>t;
 while(t--)
 {
  cin>>n;
  if(n&1)
  {
   cout<<7;
   for(int i=1;i<=n-3;i+=2)
   cout<<1;
   cout<<endl;
   } 
   else 
   {
    for(int i=1;i<=n;i+=2)
    {
     cout<<1;
    }
    cout<<endl;
   }
 }
 
 } 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!