Cf 150 & amp; 152 div 2

Source: Internet
Author: User

#150 I forgot to write a problem-solving report last time, but I want to go back and try again recently because of the poor performance.
#152 what I did last night is also very bad. Recently I stayed up late and couldn't help it.
Write this article first and complete the Code. This is a reminder.
Round #150
A. It's too watery.
B.
[Cpp]
Ll n;
Set <int> ss;
Void dfs (ll x, int y, int z) // x is the constructed number, and y and z are two numbers, respectively, x is constructed by using two numbers, y and z.
{
If (x> n) return;
Ss. insert (x );
If (x = 0 & y = 0 & z = 0) return;
If (x = 0 & y = 0 ))
{
Dfs (x + z, y, z );
}
Else if (x = 0 & z = 0)
{
Dfs (x + y, y, z );
}
Else
{
Dfs (x * 10 + y, y, z );
Dfs (x * 10 + z, y, z );
}
}
Void solveB ()
{
Cin> n;
For (int I = 0; I <10; I ++)
For (int j = 0; j <10; j ++)
Dfs (0, I, j );
Cout <ss. size ()-1 <endl;
}
C
D
E
Round #152
A. Water question.
B. At first, I thought it was a JAVA attack. Because it was a maximum of 210 loops, I thought it could be done. I didn't expect it to be TLE, because it was too time-consuming to calculate the large numbers of JAVA. A pow (10 ^ 5) times out.
Then we typed a table with 4-bits and found that the last three bits have cyclic segments. These values are 200,110, 80, and respectively.
The next step is simple.
[Cpp]
String aa [] = {"50", "80", "170", "20", "200", "110 "};
Void solveB ()
{
Int n;
Cin> n;
If (n <= 2)
Cout <-1 <endl;
Else
{
If (n = 3)
Cout <210 <endl;
Else
{
Int l = n-1-aa [(n-4) % 6]. size ();
Cout <1;
For (int I = 0; I <l; I ++)
Cout <0;
Cout <aa [(n-4) % 6] <endl;
}
}
}
C
D
E
Too much water, so I have to answer other question...

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.