第九题(NOIP2012)
#include<iostream>
using namespace std;
const int SIZE=20;
int data[SIZE];
int n,i,h,ans;
void merge(){
data[h-1] = data[h-1] + data[h];
h--;
ans++;
}
int main(){
cin>>n;
h=1;
data[h]=1;
ans=0;
for(i=2;i<=n;i++){
h++;
data[h]=1;
while(h>1 && data[h]==data[h-1])
merge();
}
cout<<ans<<endl;
}
- 【判断题】去掉第15行,程序输出结果不变。
{{ select(1) }}
- 【判断题】输入5,输出结果为3。
{{ select(2) }}
- 【判断题】将第19行的"=="改为">="程序输出结果会改变。
{{ select(3) }}
- 【判断题】输入2147483647,程序一定正常运行。
{{ select(4) }}
- 【选择题】输入2012,输出结果为( )。
{{ select(5) }}
- 【选择题】ans的上界为( )。
{{ select(6) }}
- n
- n
- log₂n
- nn