链接:https://ac.nowcoder.com/acm/contest/331/J
来源:牛客网
小希最近想知道一个东西,就是A+B=A|B(其中|为按位或)的二元组有多少个。
当然,直接做这个式子对小希来说太难了,所以小希改变了一些条件,她仅想知道其中A,B<N的情况,其中N为2的幂次。
1 #include<stdio.h> 2 #include<math.h> 3 typedef long long ll; 4 const int mod=998244353; 5 6 ll m_pow(ll a,ll b) { 7 ll tmp=a%mod; 8 ll sum=1; 9 while(b) { 10 if(b&1) sum=(sum*tmp)%mod; 11 tmp=tmp*tmp%mod; 12 b>>=1; 13 } 14 return sum; 15 } 16 17 int main() { 18 int m; 19 scanf("%d",&m); 20 printf("%lld",m_pow(3,m)); 21 return 0; 22 }
原文:https://www.cnblogs.com/ACMerszl/p/10346462.html