Uva 679
- #include <iostream>
- using namespace std;
- unsigned int reversebit (int iNumber, int iDepth )
- {
- unsigned int iTar = 0;
- while ( iDepth-- )
- {
- iTar = iTar << 1; // left shift;
- iTar = iTar | (iNumber & 1); // put iNumbers' last digit to iTar
- iNumber = iNumber >> 1; // remove last digit
- }
- return iTar;
- }
- int main()
- {
- int iTestC, iD, iI;
- int i,j, iTemp;
- cin >> iTestC;
- while ( iTestC )
- {
- cin >> iD >> iI;
- cout << reversebit ((iI+iI-1),(iD)) << endl;
- iTestC--;
- }
- }
參考 http://naivered.github.io/2016/03/19/Problem_Solving/UVa/UVa-679-Dropping-Balls/
留言
張貼留言