首页 > 其他分享 >Eigensequence UVA - 11133

Eigensequence UVA - 11133

时间:2023-04-21 22:27:43浏览次数:35  
标签:Eigensequence int a1 11133 sov UVA 80 include

给你一个递增序列的第一位a1,最后一位an,求有多少个序列满足:

以a1为首,an为尾

 

1、B(1) = A(1)

2、后面每项满足 A[j]=B[j],  A(j-1) < B(j) ≤ A(j), 且bj能整除A(j) - A(j-1)。

 

 

  F[ i ] [ j ] 最后一位为j 的方案数

#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=50;
int f[80][80] ,n ,a1,an;
 void sov(){
 	int i,j; 
 	memset(f,0,sizeof f) ;
 	
 	f[1][a1]=1;
 	for(i=2;i<=N;i++)
 		for(j=i+a1-2;j<=N;j++){
 			if(f[i-1][j])
 			for(int k=j+1;k<=N;k++){
 				if(k%(k-j)==0)
 				f[i][k]+=f[i-1][j] ;
 			}
 		}
 	
 	int ans=0;
 	for(j=1;j<=N;j++)  ans+=f[j][an];
 	cout<<a1<<' '<<an<<' '<<ans<<endl;
 }
 signed main(){
	while(cin>>a1>>an,a1||an) sov();
    return 0;
}

 

标签:Eigensequence,int,a1,11133,sov,UVA,80,include
From: https://www.cnblogs.com/towboa/p/17342019.html

相关文章

  • UVA Children’s Game(贪心)
    Description4thIIUCInter-University ProgrammingContest,2005AChildren’sGameInput:standardinputOutput:standardoutputProblemsetter: Md. KamruzzamanTherearelotsofnumbergamesforchildren.Thesegamesareprettyeasytoplaybutnotsoeasyt......
  • UVA Immediate Decodability(简单字典树)
    ImmediateDecodabilityTimeLimit:3000MS     MemoryLimit:0KB     64bitIOFormat:%lld&%lluSubmit StatusDescription  ImmediateDecodability Anencodingofasetofsymbolsissaidtobe immediately decodableifnocode......
  • UVA10237 Bishops
      #include<iostream>#include<cstring>#include<queue>usingnamespacestd;constintN=2e5+2;#defineintlonglongintn,m,f1[50][2000],f2[50][2000];voidsov(){ memset(f1,0,sizeoff1);memset(f2,0,sizeoff2); f1[0][0]=f2......
  • UVA How Many Points of Intersection?
      HowManyPointsofIntersection? a dotsonthetoprowand b dotsonthebottomrow.Wedrawlinesegmentsconnectingeverydotonthetoprowwitheverydotonthebottomrow.Thedotsarearrangedinsuchawaythatthenumberofinternalintersectio......
  • (UVA) The ? 1 ? 2 ? ... ? n = k problem
    The?1?2?...?n=kproblemTheproblemGiventhefollowingformula,onecansetoperators'+'or'-'insteadofeach'?',inordertoobtainagivenk?1?2?...?n=kForexample:toobtaink=12,theexp......
  • How Many O's? UVA - 11038
    写下区间[a,b]的所有数 ,问一共有多少个0 #include<iostream>#include<cstring>#include<vector>usingnamespacestd;#defineintlonglongintn,f[40][40][2][2];vector<int>a;intdfs(intx,intcnt0,intflg,intlead){ if(x<0){ i......
  • Investigating Div-Sum Property UVA - 11361
     定问在[A,B]中,有多少个整数本身能被m整除,各个数位上数字之和也能被m整除?  #include<iostream>#include<cstring>#include<vector>usingnamespacestd;vector<int>a;intm,f[40][105][105][2];intdfs(intx,intv1,intv2,intflg){ if(x<0) retur......
  • UVA11806 Cheerleaders
    你有一个n×m的网格图,现在你要将K个人放在网格中,满足一下条件:网格图的四个边都至少有一个人。每个格子上不能有两个人。每个人必须都有位置。注意:四个角的人可以同时算作在两个边上  容斥原理   J=0时就是allAnswer#include<iostream>#include<cstri......
  • Hackers' Crackdown UVA11825
    你需要将n个集合分成尽量多组,使得每一组里面所有集合的并集等于全集  32122022014111013120   f[S]=max(f[S],f[S-j]+1)且j是一个包含所有点的集合#include<iostream>#include<algorithm>#include<cstring>usingname......
  • Robotruck UVA - 1169
    有n个垃圾,第i个垃圾的坐标为(xi,yi),重量为wi。有一个机器人,要按照编号从小到大的顺序捡起所有垃圾并扔进垃圾桶(垃圾桶在原点(0,0))。机器人可以捡起几个垃圾以后一起扔掉,但任何时候其手中的垃圾总重量不能超过最大载重C。两点间的行走距离为曼哈顿距离(即横坐标之差的绝对值加上纵......