我是靠谱客的博主 沉静小丸子,这篇文章主要介绍UPC 问题 L: Shift only,现在分享给大家,希望可以做个参考。

问题 L: Shift only
时间限制: 1 Sec 内存限制: 128 MB
提交: 286 解决: 223
[提交] [状态] [讨论版] [命题人:admin]
题目描述

There are N positive integers written on a blackboard: A1,…,AN.
Snuke can perform the following operation when all integers on the blackboard are even:
Replace each integer X on the blackboard by X divided by 2.
Find the maximum possible number of operations that Snuke can perform.

Constraints
1≤N≤200
1≤Ai≤109

输入

Input is given from Standard Input in the following format:
N
A1 A2 … AN

输出

Print the maximum possible number of operations that Snuke can perform.

样例输入

3
8 12 40

样例输出

2

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<bits/stdc++.h> using namespace std; int del(int a[],int n,int flag) { for(int i=0;i<n;i++){ a[i]=a[i]/2; if(a[i]%2!=0) flag=0; } return flag; } int main() { int n;cin>>n; int num[n]; int flag=1; int cnt=0; for(int i=0;i<n;i++) { cin>>num[i]; if(num[i]%2!=0) flag=0; } if(flag==0) cout<<"0"<<endl; else { while(flag==1){ flag=del(num,n,flag); cnt++; } cout<<cnt<<endl; } return 0; }

最后

以上就是沉静小丸子最近收集整理的关于UPC 问题 L: Shift only的全部内容,更多相关UPC内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(82)

评论列表共有 0 条评论

立即
投稿
返回
顶部