#10750. 数论第九题(NOIP2012)

数论第九题(NOIP2012)

第九题(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;
}
  1. 【判断题】去掉第15行,程序输出结果不变。
    {{ select(1) }}
  • 正确
  • 错误
  1. 【判断题】输入5,输出结果为3。
    {{ select(2) }}
  • 正确
  • 错误
  1. 【判断题】将第19行的"=="改为">="程序输出结果会改变。
    {{ select(3) }}
  • 正确
  • 错误
  1. 【判断题】输入2147483647,程序一定正常运行。
    {{ select(4) }}
  • 正确
  • 错误
  1. 【选择题】输入2012,输出结果为( )。
    {{ select(5) }}
  • 2015
  • 2018
  • 2004
  • 2006
  1. 【选择题】ans的上界为( )。
    {{ select(6) }}
  • n
  • n\sqrt{n}
  • log₂n
  • nnn\sqrt{n}