当前位置:网站首页>【CF#697 (Div. 3)】 A - Odd Divisor

【CF#697 (Div. 3)】 A - Odd Divisor

2022-06-11 07:10:00 percation

Odd Divisor


The main idea of the topic , Judge the input number n n n Whether there is Odd factor , If there is, then YES, otherwise NO.


When n n n In an odd number of , accord with YES
That is, just judge n For even when ( Such as 6,12,30 etc. ), Whether there is an odd factor
because ,2 Power square ( To the power of 1 Start , because n>=2), There must be no odd factor
therefore , Take will n n n % 2, If it's worth 0, Will n n n /= 2, Circular judgement n n n%2 Is it 0.
If finally n Result > 1, Then there is an odd factor . conversely , Otherwise .

/* * author: percation * date: 2022.2.27 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
ll n;
ll t;
int main(){
    
	cin >> t;
	while(t--){
    
		cin >> n;
		while(n % 2 == 0){
    
			n /= 2;
		}
		if(n > 1){
    
			cout << "YES" << endl;
		}
		else{
    
			cout <<"NO" << endl;
		}
	}
	
	
	return 0;
}
原网站

版权声明
本文为[percation]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020522591584.html