Fixed Point Problem Solving report

Source: Internet
Author: User

Summary:

The key point of this number theory motion rule is the "processing of the same number as the previous session". As long as this is understood, this question should be done.

Because there is only one number equal to the previous session, I use an equal to record whether the previous session meets the conditions. The other values smaller than the previous values are stored in the f array.

The policy only takes 1 and 0.

The value smaller than the previous number can be obtained at will.

Think about equal status transfer:

The current BIT is 1: If the value is 1, equal is retained. If the value is 0, equal can be transferred to the f array.

The current BIT is 0: If the value is 0, equal is retained. 1 is bigger than the previous one.

 

General summary:

1. Draft analysis sample is very effective.

2. The habit of directly using unproven conclusions is not good. This question and Coprime sequence have already had a deep understanding.

 1 #include <iostream> 2 #include <cstdlib> 3 #include <cstdio> 4 #include <cstring> 5 #define FOR(i,l,r) for(int i=(l);i<=(r);i++) 6 #define FORD(i,r,l) for(int i=(r);i>=(l);i--) 7 #define rep(i,n) for(int i=0;i<(n);i++) 8 using namespace std; 9 typedef long long LL;10 typedef unsigned int ui;11 ui get2[33];12 13 LL f[33][33];14 LL gao(ui R, ui c, int k, int flag)15 {16     memset(f,0,sizeof(f));17     LL equal=1; int gs0=0;18     FORD (z,31,0)19     {20         //021         if (flag>=0 || !(c&get2[z]))22         {23             FOR (i,1,32-z) f[z][i]=f[z+1][i-1];24             if (R&get2[z]) f[z][gs0+1]+=equal;25         }26         //127         if (flag<=0 || (c&get2[z]))28         {29             FOR (i,0,31-z) f[z][i]+=f[z+1][i];30         }31         if ((R&get2[z]) && !(flag<=0 || (c&get2[z]))) equal=0;32         if (!(R&get2[z]) && !(flag>=0 || !(c&get2[z]))) equal=0;33         gs0+=!(R&get2[z]);34     }35     LL ret=0;36     FOR (i,0,32) if (abs(32-i-i)<=k) ret+=f[0][i];37     if (abs(32-gs0*2)<=k) ret+=equal;//~~38     return ret;39 }40 41 ui L,R,c; int k;42 LL gao0(int flag)43 {44     LL ret=gao(R,c,k,flag);45     if (L) ret-=gao(L-1u,c,k,flag);46     return ret;47 }48 49 int main()50 {51     get2[0]=1; for (int i=1;i<=32;i++) get2[i]=get2[i-1]<<1;52 53     int T; scanf("%d",&T);54     LL ans1,ans2,ans3;55     FOR (z,1,T)56     {57         scanf("%u%u%u%d",&L,&R,&c,&k);58         ans1=gao0(1);59         if (c!=0) ans2=0; else ans2=gao0(0);60         ans3=gao0(-1);61         printf("Case %d: %lld %lld %lld\n",z,ans1,ans2,ans3);62     }63     return 0;64 }
Fixed Point Code

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.