我是靠谱客的博主 淡淡金鱼,最近开发中收集的这篇文章主要介绍BC21&&hdoj5138&&hdoj5139&&hdoj5141 CET-6 test Formula LIS again,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
CET-6 test
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 613 Accepted Submission(s): 440
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.
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
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
Source
BestCoder Round #21
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<vector>
using namespace std;
const int maxn=1010;
int num[10]={1,2,4,7,15};
int main()
{
int t,i,j,k,n;
while(scanf("%d",&n)!=EOF){
for(i=4;i>=1;--i){
if(n-num[i]>0)printf("%d ",n-num[i]);
}
printf("%dn",n-1);
}
return 0;
}
Formula
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1157 Accepted Submission(s): 399
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.
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
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
Source
BestCoder Round #21
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<cmath>
#include<vector>
#define MOD 1000000007
using namespace std;
const int maxn=100010;
int num[maxn];
struct Node{
int x,y,ans;
}A[maxn];
bool cmp(Node a,Node b){
return a.x<b.x;
}
void init(int n){
int num[5],cnt=0;num[0]=num[1]=1;
while(A[cnt].x==1){
A[cnt].ans=1;cnt++;
}
for(int i=2;i<=n;++i){
num[i%3]=(long long)num[(i-1)%3]*i%MOD;
num[(i-1)%3]=(long long)num[(i-2)%3]*num[i%3]%MOD;
while(i==A[cnt].x){
A[cnt].ans=num[(i-1)%3];cnt++;
}
}
}
bool cmp1(Node a,Node b){
return a.y<b.y;
}
int main()
{
int i,n=0;
while(scanf("%d",&A[n].x)!=EOF){
A[n].y=n;n++;
}
sort(A,A+n,cmp);
init(A[n-1].x);
sort(A,A+n,cmp1);
for(i=0;i<n;++i){
printf("%dn",A[i].ans);
}
return 0;
}
LIS again
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 493 Accepted Submission(s): 184
Problem Description
A numeric sequence of ai is ordered if
a1<a2<…<aN
. Let the subsequence of the given numeric sequence (
a1,a2,…,aN
) be any sequence (
ai1,ai2,…,aiK
), where
1≤i1<i2<…<iK≤N
. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered subsequences, eg. (1, 7), (3, 4, 8) and many others.
S[ i , j ] indicates ( ai,ai+1,ai+2,…,aj ) .
Your program, when given the numeric sequence ( a1,a2,…,aN ), must find the number of pair ( i, j) which makes the length of the longest ordered subsequence of S[ i , j ] equals to the length of the longest ordered subsequence of ( a1,a2,…,aN ).
S[ i , j ] indicates ( ai,ai+1,ai+2,…,aj ) .
Your program, when given the numeric sequence ( a1,a2,…,aN ), must find the number of pair ( i, j) which makes the length of the longest ordered subsequence of S[ i , j ] equals to the length of the longest ordered subsequence of ( a1,a2,…,aN ).
Input
Multi test cases (about 100), every case occupies two lines, the first line contain n, then second line contain n numbers
a1,a2,…,aN
separated by exact one space.
Process to the end of file.
[Technical Specification]
1≤n≤100000
0≤ai≤1000000000
Process to the end of file.
[Technical Specification]
1≤n≤100000
0≤ai≤1000000000
Output
For each case,.output the answer in a single line.
Sample Input
3 1 2 3 2 2 1
Sample Output
1 3
Source
BestCoder Round #21
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<vector>
using namespace std;
const int maxn=100010;
int dp[maxn][2],n;//dp[i][0]记录前i个的最长上升序列长度dp[i][1]记录该序列开头的第一个元素的位置
int la[maxn],lb[maxn],pos[maxn];
long long LIS(){
dp[1][0]=1;dp[1][1]=1;
memset(pos,0,sizeof(pos));//记录开头位置
lb[1]=la[1];int len=1;pos[1]=1;
for(int i=2;i<=n;++i){
int left=1,right=len;
if(la[i]>lb[len]){
len++;lb[len]=la[i];
pos[len]=max(pos[len],pos[len-1]);
dp[i][0]=len;dp[i][1]=pos[len];
continue;
}
while(left<=right){
int mid=(left+right)>>1;
if(la[i]>lb[mid]){
left=mid+1;
}
else {
right=mid-1;
}
}
lb[left]=la[i];
if(left==1)
pos[left]=i;
else
pos[left]=max(pos[left],pos[left-1]);
dp[i][0]=left;dp[i][1]=pos[left];
}
int l=0;
long long ans=0;
for(int i=1;i<=n;++i){
if(dp[i][0]==len){
l=max(l,dp[i][1]);
}
ans=ans+l;
}
return ans;
}
int main()
{
int i,j,k;
while(scanf("%d",&n)!=EOF){
for(i=1;i<=n;++i){
scanf("%d",&la[i]);
}
printf("%lldn",LIS());
}
return 0;
}
最后
以上就是淡淡金鱼为你收集整理的BC21&&hdoj5138&&hdoj5139&&hdoj5141 CET-6 test Formula LIS again的全部内容,希望文章能够帮你解决BC21&&hdoj5138&&hdoj5139&&hdoj5141 CET-6 test Formula LIS again所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复