bestcoder round #21

1001 CET-6 test

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]
2≤n≤100000

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

题解

没什么好说的,大水题。开始的时候还PE了两发……对此表示遗憾……

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include<vector>
using namespace std;

int ()
{
int n;

while(cin>>n)
{
vector<int> v;
int i;
if(n-15>0) v.push_back(n-15);
if(n-7>0) v.push_back(n-7);
if(n-4>0) v.push_back(n-4);
if(n-2>0) v.push_back(n-2);
if(n-1>0) v.push_back(n-1);
for( i=0;i<v.size()-1;i++)
cout<<v[i]<<" ";
cout<<v[i];
cout<<endl;


}
return 0;
}

1002 Formula

Problem Description
f(n)=(∏i=1nin−i+1)%1000000007
You are expected to write a program to calculate f(n) when a certain n is given.

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

[Technical Specification]
1≤n≤10000000

Output
For each n,output f(n) in a single line.

Sample Input
2
100

Sample Output
2
148277692

题解

输入n,输出n!*(n-1)!*……1!,每十个数据储存一个,最后计算

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cstdio>
#include <iostream>
#include<fstream>
using namespace std;
const int maxn = 1000100;
const int MOD =1000000007;
int d[maxn],f[maxn];
int ()
{
d[0]=1;
f[0]=1;
int k=1,i,n;
long long td=1,fd=1;
for(i=2; i<=10000000;i++)
{
fd=fd*i%MOD;
td=td*fd%MOD;
if(i%10==0)
{
d[k]=td;
f[k++]=fd;
}
}
while(cin>>n)
{
int pos=n/10;
int len=n%10;
td=d[pos],fd=f[pos];
for(k=1,i=n/10*10+1;k<=len; k++,i++)
{
fd=fd*i%MOD;
td=td*fd%MOD;
}
cout<<td<<endl;
}
return 0;
}