can I use #ifdef, #elif #endif here?

#ifdef is a preprocessor directive, meaning that is reduced/optimized at compile time, therefore the values must be know at compile time.

You cannot because cycles is a runtime variable and the value of cycles is not know during compilation.

There does appear to be some possible ways to reduce the code. You'll have to change your thinking a bit. The premise is based on the fact that two lines appear in 5 of the 6 cases (ie., you have replicated code), furthermore the if criteria (*1, *8, *64) is also used in the formula of the if statement.