2018 National multi-school algorithm winter training Camp practice Competition (first game) Lulu

Source: Internet
Author: User

The Lulu of the breakthrough

Links: Https://www.nowcoder.com/acm/contest/67/J
Source: Niu Ke Net

Title Description

The brave Lulu entered a 10,000,000-storey tower one day, and in the tower every floor, he would get a corresponding number of 0 1 (see the situation obtained), and then there is a law in the tower, when you have a number to a certain number, they meet to become the next number, now the problem, What is the number of Lulu when he reaches the nth level from layer 1?

1th Floor 0

2nd Floor 11

3rd Floor 110

4th Floor 21

5th Floor 210

6th Floor 22

7th Floor 220

8th Floor 2211

9th Floor 22110

10th Floor 2221

11th Floor 22210

12th Level 3 input Description:

The first line is the sample number T (t<100)
from 2 to 2+t-1 each line has an integer n (0<n<=10^7).
Output Description:
Numbers from large to small output lulu to the nth layer
Example 1 input
4
1
2)
3
20
Output
0
32211
remark:
For 100% data,
0 < T <=
0 < n <= 10^7

This problem is actually not the law I found out.

At the time of the game, Czc said a little bit about the law he found, and then I didn't know how to realize the time, and I didn't write it.

I'm going to make a supplement today.

It's a very simple way to write a long time and feel like I'm really not sure.

I wrote some ideas today, but it's still a little messy.

Write a little clearer later.

I don't know how to express it.

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

int t,n;
const int MAXN = 1E7;
int num[10000003];


int main ()
{
	scanf ("%d", &t);
	while (t--) {
        scanf ("%d", &n);
        int now = 1, times = 3;
        Num[0] = n% 2;
        int tmp = (n-num[0])/2 + N/2;
        NUM[1] = tmp% 3;
        TMP = TMP/3;
        while (TMP) {
            Num[++now] = tmp% (times + 1);
            TMP = TMP/(times + 1);
            times++;
        }

        for (int i = Now, I >= 0; i--) {while
            (num[i]--) {
                cout<<i;
            }
        }
        cout<< Endl;
	}
	return 0;
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.