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;
}