Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll arr[32];
for(int i = 0; i < 32; i++){
arr[i] = pow(2, i+1) - 1;
}
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
for(int i = 1; i < 32; i++){
if(n % arr[i] == 0){
cout<<(n/arr[i])<<endl;
break;
}
}
}
}
Copy The Code &
Try With Live Editor
Input
7
3
6
7
21
28
999999999
999999984
3
6
7
21
28
999999999
999999984
Output
1
2
1
7
4
333333333
333333328
2
1
7
4
333333333
333333328
Demonstration
Codeforcess solution 1343-A A. Candies ,C++, Java, Js and Python,1343-A