SAC#1 - 组合数
SAC#1 - 组合数
题意简化 \(:\)
对杨辉三角的某一行的偶数位置求和.
我们知道,杨辉三角的某一行和是 \(2^n\).
那么答案是否就是 \(2^{n-1}\) 呢?是的.
因为杨辉三角是对称的.
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define pii pair < int , int >
#define one first
#define two second
#define rint read<int>
#define int long long
#define pb push_back
#define db double
#define ull unsigned long long
#define lowbit(x) ( x & ( - x ) )
using std::queue ;
using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::swap ;
using std::sort ;
using std::unique ;
using std::greater ;
template < class T >
inline T read () {
T x = 0 , f = 1 ; char ch = getchar () ;
while ( ch < '0' || ch > '9' ) {
if ( ch == '-' ) f = - 1 ;
ch = getchar () ;
}
while ( ch >= '0' && ch <= '9' ) {
x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
ch = getchar () ;
}
return f * x ;
}
int n ;
const int mod = 6662333 ;
inline int quick (int a , int p) {
int res = 1 ;
while ( p ) {
if ( p & 1 ) res = ( res * a ) % mod ;
a = ( a * a ) % mod ; p >>= 1 ;
}
return res ;
}
signed main (int argc , char * argv[]) {
n = rint () ;
printf ("%lld\n" , quick ( 2ll , n - 1 ) ) ;
system ("pause") ; return 0 ;
}
May you return with a young heart after years of fighting.