#38. 模拟策略第八题(NOIP2009)

模拟策略第八题(NOIP2009)

第八题(NOIP2009)

#include<iostream>
using namespace std;
const int c=2009;
int main() {
    int n,p,s,i,j,t;
    cin>>n>>p;
    s=0;t=1;
    for(i=1;i<=n;i++) {
        t=t*p%c;
        for(j=1;j<=i;j++)
            s=(s+t)%c;
    }
    cout<<s<<endl;
    return 0;
}
  1. 【判断题】将12-13行改为s=(s+111ti)%c,程序输出不会改变。 {{ select(1) }}
  • 正确
  • 错误
  1. 【判断题】将15行改为printf("%d\n",s);程序输出不会改变。 {{ select(2) }}
  • 正确
  • 错误
  1. 【判断题】将08行的s=0;去掉,程序输出不会改变。 {{ select(3) }}
  • 正确
  • 错误
  1. 【判断题】将03行const去掉,程序输出不会发生变化。 {{ select(4) }}
  • 正确
  • 错误
  1. 【选择题】输入为11 2,输出为( )。 {{ select(5) }}
  • 782
  • 762
  • 802
  • 114
  1. 【选择题】该算法的时间复杂度为( )。 {{ select(6) }}
  • O(1)
  • O(n)
  • O(n²)
  • O(nlogn)