hdu 5138 CET-6 test(BestCoder Round #21)

CET-6 test

                                                              Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
                                                                                        Total Submission(s): 90    Accepted Submission(s): 74


Problem Description
Small W will take part in CET-6 test which will be held on December  20th . In order to pass it he must remember a lot of words.
He remembers the words according to Ebbinghaus memory curve method.
He separates the words into many lists. Every day he picks up a new list, and in the next  1st,2nd,4th,7th,15th  day, he reviews this list.
So every day he has many lists to review. However he is so busy, he does not know which list should be reviewed in a certain day. Now he invites you to write a program to tell him which list should to be reviewed in a certain day.
Lists are numbered from 1. For example list 1 should be reviewed in the  2nd,3rd,5th,8th,16th  day.
 

Input
Multi test cases (about 100), every case contains an integer n in a single line. 
Please process to the end of file.

[Technical Specification]
2n100000
 

Output
For each n,output the list which should be reviewed in the  nth  day in ascending order.
 

Sample Input
   
   
   
   
2 100
 

Sample Output
   
   
   
   
1 85 93 96 98 99
 

求第n天要复习的内容,要复习前1,2,4,7,15天的内容,其实只要用个数组存下要减的天数并判断是否大于0就可以了,当时脑抽直接分类讨论了,这样容易错。

代码:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n<3)
        {
            printf("%d\n",n-1);
        }
        else if(n<5)
        {
            printf("%d %d\n",n-2,n-1);
        }
        else if(n<8)
        {
            printf("%d %d %d\n",n-4,n-2,n-1);
        }
        else if(n<16)
        {
            printf("%d %d %d %d\n",n-7,n-4,n-2,n-1);
        }
        else
        {
            printf("%d %d %d %d %d\n",n-15,n-7,n-4,n-2,n-1);
        }
    }
    return 0;
}


你可能感兴趣的:(Algorithm,ACM,BestCoder)