woj1010- Alternate Sum

来源:互联网 发布:外貌协会 知乎 编辑:程序博客网 时间:2024/06/06 12:37

公式题,ans=(max*2^(n-1))%2006;

#include <iostream> #include<cstdio>  using namespace std;    const int MaxN = 1 << 30;    int main()  {      int n;      while(1 == scanf("%d", &n) && n )   {          int maxx;          scanf("%d", &maxx);          for(int i = 0; i < n - 1; i++)         {              int t;              scanf("%d", &t);              maxx = max(maxx, t);          }          maxx %= 2006;          if(maxx < 0) maxx += 2006;          for(int i = 0; i < n - 1; i++)         {              maxx *= 2;              maxx %= 2006;          }          printf("%d\n", maxx % 2006);      }      return 0;  }  


原创粉丝点击