CF 1475A - Odd Divisor
You are given an integer n. Check if n has an odd divisor, greater than one (does there exist such a number x (x>1) that n is divisible by x
?and x is odd).
For example, if n=6, then there is x=3. If n=4, then such a number does not exist.
Input
The first line contains one integer t (1≤t≤104) — the number of test cases. Then t test cases follow.
Each test case contains one integer n (2≤n≤1014).
Please note, that the input for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language.
Output
For each test case, output on a separate line:"YES" if n has an odd divisor, greater than one;"NO" otherwise.
You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).
---------------------------------------
給定一個(gè)整數(shù) n。 檢查 n 是否有一個(gè)大于 1 的奇數(shù)約數(shù)(是否存在這樣的數(shù)字 x (x>1) 使得 n 可以被 x 整除
? x 是奇數(shù))。
例如,如果n=6,則x=3。 如果n=4,那么這樣的數(shù)不存在。
輸入
第一行包含一個(gè)整數(shù) t (1≤t≤104) — 測(cè)試用例的數(shù)量。 然后是測(cè)試用例。
每個(gè)測(cè)試用例包含一個(gè)整數(shù)n(2≤n≤1014)。
請(qǐng)注意,某些測(cè)試用例的輸入不適合 32 位整數(shù)類型,因此您應(yīng)該在編程語(yǔ)言中至少使用 64 位整數(shù)類型。
輸出
對(duì)于每個(gè)測(cè)試用例,在單獨(dú)的行上輸出:如果 n 具有大于 1 的奇數(shù)除數(shù),則輸出“YES”;否則輸出“NO”。
您可以在任何情況下輸出“YES”和“NO”(例如,字符串 yEs、yes、Yes 和 YES 將被識(shí)別為正數(shù))。
----------------------------------------------
如果這個(gè)數(shù)是奇數(shù),那么它肯定是yes的,如果這個(gè)數(shù)是偶數(shù),那么就要一直除以2,去看最后的商是否大于1,如果大于1,那么是yes的,如果等于1,那就是NO的;
下面待代碼: