A:
描述:
代码:
1 #include <iostream> 2 #include <stdio.h> 3 #include <math.h> 4 #include <string.h> 5 using namespace std; 6 7 int k,p; 8 int a[104]; 9 //void solve(){ 10 // int ans=0; 11 // for(int i=1;i<=k;i++){ 12 // ans=0; 13 // for(int j=1;j<=p-1;j++){ 14 // ans+=(int)pow(j,i); 15 // } 16 // a[i]=(ans%p+p)%p; 17 // } 18 // for(int i=1;i<=k;i++){ 19 // cout<<a[i]<<" "; 20 // } 21 // cout<<endl; 22 //} 23 int main() 24 { 25 while(~scanf("%d%d",&k,&p)){ 26 // solve(); 27 int s=k/(p-1); 28 if(s%2==1) printf("YES\n");else printf("NO\n"); 29 } 30 }
B:
描述:
代码:
C:
D:
描述:
代码:
1 #include <iostream> 2 #include <string.h> 3 #include <stdio.h> 4 #include <algorithm> 5 #define LL long long 6 using namespace std; 7 8 int N,M; 9 struct Node{ 10 LL l,t; 11 bool operator<(const Node &X)const{ 12 if (l==X.l) return t>X.t; 13 else return l>X.l; 14 } 15 void print(){ 16 cout<<"l="<<l<<","<<"t="<<t<<endl; 17 } 18 }P1[100100],P2[100100]; 19 int vis[105]; 20 int main(){ 21 while(~scanf("%d%d",&N,&M)){ 22 LL l,t; 23 for(int i=0;i<N;i++){ 24 scanf("%I64d%I64d",&l,&t); 25 P1[i]=(Node){l,t}; 26 } 27 for(int i=0;i<M;i++){ 28 scanf("%I64d%I64d",&l,&t); 29 P2[i]=(Node){l,t}; 30 } 31 sort(P1,P1+N); 32 sort(P2,P2+M); 33 memset(vis,0,sizeof(vis)); 34 LL score=0,num=0; 35 int i=0,j=0; 36 for(;i<M;i++){ 37 while(j<N&&P1[j].l>=P2[i].l){ 38 vis[P1[j].t]++; 39 j++; 40 } 41 for(int t=P2[i].t;t<=100;t++){ 42 if (vis[t]){ 43 num++; 44 vis[t]--; 45 score+=500*P2[i].l+2*P2[i].t; 46 break; 47 } 48 } 49 } 50 printf("%I64d %I64d\n",num,score); 51 } 52 return 0; 53 }
E:
F:
G:
H:
I:
描述:
代码:
1 #include <iostream> 2 #include <string.h> 3 #include <stdio.h> 4 #include <algorithm> 5 #define Mod 1000000009 6 #define LL long long 7 using namespace std; 8 9 int N,M; 10 LL F[100100]; 11 void builtF(){ 12 F[0]=1; 13 for(int i=1;i<=100000;i++){ 14 F[i]=(F[i-1]*i)%Mod; 15 } 16 return ; 17 } 18 LL QuickMod(LL a,LL p){ 19 LL ans=1; 20 while(p){ 21 if (p&1){ 22 ans=(ans*a)%Mod; 23 p--; 24 } 25 p>>=1; 26 a=(a*a)%Mod; 27 } 28 return ans; 29 } 30 int main(){ 31 builtF(); 32 while(~scanf("%d%d",&N,&M)){ 33 int l1=0,l2,r1=0,r2; 34 for(int i=0;i<N;i++){ 35 int x; 36 scanf("%d",&x); 37 if (l1>=x) l2=l1-x; 38 else if (r1>=x) { 39 if (l1%2==x%2) l2=0;else l2=1; 40 }else l2=x-r1; 41 if (r1+x<=M) r2=r1+x; 42 else if (l1+x<=M) { 43 if ((l1+x)%2==M%2) r2=M;else r2=M-1; 44 }else r2=2*M-(l1+x); 45 l1=l2,r1=r2; 46 } 47 LL ans=0; 48 for(int i=l1;i<=r1;i+=2){ 49 ans+=((F[M]%Mod)*(QuickMod(F[i]*F[M-i]%Mod,Mod-2)%Mod))%Mod; 50 } 51 printf("%I64d\n",ans%Mod); 52 } 53 return 0; 54 }
J:
描述:
代码:
1 #include <iostream> 2 #include <string.h> 3 #include <stdio.h> 4 #include <algorithm> 5 #define Mod 1000000009 6 #define LL long long 7 using namespace std; 8 9 double T[30]; 10 double p,ans,q; 11 int main(){ 12 while(~scanf("%lf",&p)){ 13 q=1-p; 14 ans=0; 15 T[0]=1/p;T[1]=T[0]/p;T[2]=T[1]/p; 16 ans+=T[0]+T[1]+T[2]; 17 for(int i=3;i<20;i++){ 18 T[i]=(T[i-1]-T[i-3]*q)/p; 19 ans+=T[i]; 20 } 21 ans=ans*2-T[19]; 22 printf("%.6lf\n",ans); 23 } 24 return 0; 25 }
K:
时间: 2024-10-05 05:32:09