|  | 
|  | 
| вернуться в форум | WA13 Послано Milica  22 дек 2023 16:39Can someone tell me what is 13.test case? Also, is the only way to solve this problem using long arithmetic?Re: WA13 Послано fxubp  9 янв 2024 04:47Re: WA13 Послано Milica  10 янв 2024 16:06I got time exceeded error. Can somebody tell what is test case? Or tell me how can I optimize my code? I even found to solutions using dp.
 void lemontale(int n,int k,vector<vector<BigInt>> &mem){
 BigInt big_n = BigInt(n);
 BigInt big_k = BigInt(k);
 BigInt dva_big = BigInt(2ull);
 if (mem[n-1][k] == BigInt()){
 if (n<0)
 return ;
 else if (k==0 && n==1){
 mem[n-1][k] = BigInt(1);
 
 }
 else if (k==0){
 lemontale(n-1,k_start,mem);
 mem[n-1][k] = mem[n-2][k_start];
 
 }
 else if (n<=k){
 BigInt rez = dva_big^big_n;
 
 mem[n-1][k] = rez;
 }
 else{
 
 lemontale(n-1,k_start,mem);
 lemontale(n-1,k-1,mem);
 mem[n-1][k] = mem[n-2][k-1]+mem[n-2][k_start];
 }
 }
 
 }
 void lemontale2(int n,int k,BigInt* mem){
 BigInt dva_big = BigInt(2ull);
 
 if (mem[n-1]==BigInt()){
 if (n<=k)
 mem[n-1] = dva_big^BigInt(n);
 else
 for(int i=0;i<=k;i++){
 if (n-i-1 != 0){
 lemontale2(n-i-1,k,mem);
 mem[n-1]+=mem[n-i-2];
 }
 else{
 mem[n-1]+=1;
 }
 }
 }
 
 }
 
 Edited by author 10.01.2024 16:08
 
 Edited by author 10.01.2024 16:09
 
 Edited by author 10.01.2024 16:09
 
 Edited by author 10.01.2024 16:09
 | 
 | 
|