1032 Parliament

 拆成从2开始的递增数列,余下的部分倒回去加2轮,证明比较多,可以看此题的Discuss

  1. //4540529_AC_47MS_424K
  2. /**********************************************************************
  3. *       Online Judge   : POJ
  4. *       Problem Title  : Parliament
  5. *       ID             : 1032
  6. *       Date           : 1/7/2009
  7. *       Time           : 22:27:43
  8. *       Computer Name  : EVERLASTING-PC
  9. ***********************************************************************/
  10. #include<iostream>
  11. using namespace std;
  12. int n,l,k;
  13. int main()
  14. {
  15. //  freopen("in_1032.txt","r",stdin);
  16.     while (cin>>n)
  17.     {
  18.         l=n;
  19.         k=2;
  20.         while (1)
  21.         {
  22.             if (l-k<0)
  23.             {
  24.                 break;
  25.             }
  26.             l-=k;
  27.             k++;
  28.         }
  29.         k--;
  30.         for (int i=2;i<k;++i)
  31.         {
  32.             cout<<i+(i>k-l?1:0)<<' ';
  33.         }
  34.         if (k==l)
  35.         {
  36.             cout<<k+2<<endl;
  37.         }
  38.         else
  39.         {
  40.             cout<<k+(l!=0?1:0)<<endl;
  41.         }
  42.     }
  43.     return 0;
  44. }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值