Skew Binary Diagonal Binary
Each bit of the diagonal binary is 0, or 1, and the lowest bit can be 2. K-Bit of ... Represents 2k+1-1, gives a diagonal binary number, converts it to a decimal number. Normal simulation is good.
1#include <cstdio>2#include <cstring>3 Chara[ +];4 5 intMain () {6 while(SCANF ("%s", A)! =EOF) {7 if(a[0] =='0') Break;8 intLen =strlen (A);9 intAns =0;Ten for(inti = len-1; I >=0; i--) OneAns + = (A[i]-'0')* ((1<< (len-i))-1); Aprintf"%d\n", ans); - } - return 0; the}
View Code
Light, more lights
In a corridor where n bulbs were extinguished, a man walked from the 1th lamp to the nth lamp and counted it once (from the nth light to come back), this person will walk n times, every time I go to the first bulb, if n can be divided by I, he will change the state of the lamp, ask him to walk n times, the last lamp is lit
Calculate the number of factors from 1 to n,n, if it is an odd number is extinguished, even the number is bright (the first to turn over the violence of the time) ... Search the Puzzle!!
The key is to determine whether the n is a number of squares, if it will be changed state odd number of times, can be opened. P.S. The initial state of the bulb is out of the data to see ... There's going to be a burst int.
1#include <cstdio>2#include <cmath>3typedefLong LongLL;4 5 intMain () {6 LL N;7 while(SCANF ("%lld", &n)! = EOF &&N) {8ll k = (ll) sqrt (n1.0);9 if(K*k = = N) puts ("Yes");Ten ElsePuts"No"); One } A return 0; -}
View Code
Multiplying by Rotation Shift Division
3 numbers per line, n,a,b. n indicates the number of binary, a, B did not understand
Just the Facts factorial
Outputs the last non-0 number of the factorial of a number n according to the format
Idea: The last one is only related to the last one (good round), should not have several situations
1! = 1, 2! = 2, 3! = 6; 4! = 8, 5!= 4, 6! = 4, 7! = 8, 8!= 4, 9! = 6, 10! = 6, 11! = 6; 12! = 2, 13! = 6
"Rujia Algorithm Competition Introduction Classics" fifth chapter number theory