Main » 2013 October 11 » 【洛谷10.7模拟赛】偶数
7:05 AM 【洛谷10.7模拟赛】偶数 |
比赛时被卡了tot,结果拿了70评测详情编译成功
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<vector> #include<set> #include<map> #include<string> #include<algorithm> #define FOR(i,a,b) for(i=(a);i<=(b);i++) #define ROF(i,a,b) for(i=(a);i>=(b);i--) #define pb push_back #define mp make_pair #define MOD 1000003 using namespace std; typedef long long LL; typedef long double LD; LL power3(int x) { if (x==0) return 1; if (x==1) return 3; LL tmp=power3(x/2)%MOD; if (x%2) return tmp*3%MOD*tmp%MOD; return tmp*tmp%MOD; } int a[301]; int main() { ios::sync_with_stdio(false); LL n; cin>>n; LL tn=n; int i; int L=-1; while (tn) a[++L]=tn%2,tn/=2; LL ttn=n,tn1=n+1; if (ttn%2) tn1/=2;else ttn/=2; LL tot=(ttn%MOD)*(tn1%MOD); tot%=MOD; LL t=1; LL sum=0; ROF(i,L,0) if (a[i]) { LL tt=power3(i)*t%MOD; sum=(sum+tt)%MOD; t=t*2%MOD; } LL ans=(tot-sum)%MOD; while (ans<0) ans+=MOD; cout<<ans<<endl; return 0; } |
|
Total comments: 0 | |