HDOJ 1597,1058

Source: Internet
Author: User

I made another big question for a day. Write them together.

HDU1597

Code:


[Cpp]
# Include <iostream>
# Include <cmath>
Using namespace std;
Int main ()
{
Int k;
_ Int64 x, n;
Scanf ("% d", & k );
While (k --){
Scanf ("% I64d", & n );
X = int (sqrt (n * 2.0 ));
While (x * x + x> = 2 * n) x --;
X = n-(x * x + x)/2;
Printf ("% I64d \ n", (x-1) % 9 + 1 );
}
Return 0;
}

 

HDU 1058 enumeration + sorting

[Cpp]
# Include <iostream>
# Include <algorithm>
# Include <cmath>
Using namespace std;
# Define INF 0x7fffffff
Int f [10000];
Int main ()
{
_ Int64 t;
Int I, j, k, m, s, flag;
S = 0; flag = 1;
For (I = 0; I <= 12 & flag; I ++)
For (j = 0; j <= 14 & flag; j ++)
For (k = 0; k <= 20 & flag; k ++)
For (m = 0; m <= 31 & flag; m ++ ){
T = (_ int64) (pow (7.0, I) * pow (5.0, j) * pow (3.0, k) * pow (2.0, m ));
If (t <0 | t> INF) {break; flag = 0 ;}// t <0 is afraid of Overflow
Else {f [s ++] = t;
}
}
Sort (f, f + s );
While (scanf ("% d", & I ){
Printf ("The % d", I );
If (I % 10 = 1 & I % 100! = 11)
Printf ("st ");
Else if (I % 10 = 2 & I % 100! = 12)
Printf ("nd ");
Else if (I % 10 = 3 & I % 100! = 13)
Printf ("rd ");
Else
Printf ("th"); www.2cto.com
Printf ("humble number is % d. \ n", f [I-1]);
}
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.