// //

# 2019佳木斯集训 Day5

T1

大水题,题里咋说你就咋做,AC

思路:大水题

 1 #include <bits/stdc++.h>
2 using namespace std;
3 int t;
4 long long n,ans;
5 int main(){
6     scanf("%d",&t);
7     while(t--){
8         scanf("%lld",&n);
9         ans=0;
10         if(n==1){printf("0\n");continue;}
11         while(n!=1){
12             while(n%2==0) ans+=1,n/=2;
13             while(n%3==0) ans+=2,n/=3;
14             while(n%5==0) ans+=3,n/=5;
15             if(n==1) break;
16             if(n%2!=0&&n%3!=0&&n%5!=0){ans=-1;break;}
17         }
18         printf("%lld\n",ans);
19     }
20     return 0;
21 }
T1-A

T2

思维题,细节较多,总体不难

zkc大佬提醒您:十年OI一场空,不开long long见祖宗

思路:模拟deque找到序列中最大的值在第一位的时候,

 1 #include <bits/stdc++.h>
2 using namespace std;
3 long long n,nq,tail;
4 long long x,qwq,stop,maxx,ac;
5 long long a[400010];
6 long long m[300010];
7 long long ans[200020][3];
8 int main(){
9     scanf("%lld%lld",&n,&nq);
10     tail=n;
11     for(register int i=1;i<=n;i++) scanf("%lld",&a[i]),maxx=max(maxx,a[i]);
12     //printf("%lld\n",maxx);
13     for(register int i=2;i<=n;i++){
14         ans[i-1][1]=a[i-1];
15         ans[i-1][2]=a[i];
16         a[++tail]=min(a[i],a[i-1]);
17         a[i]=max(a[i],a[i-1]);
18         if(a[i]==maxx){stop=i;break;}
19     }
20     //for(register int i=1;i<=n;i++) printf("%lld %lld\n",ans[i][1],ans[i][2]);
21     //for(register int i=1;i<=tail;i++) printf("%lld ",a[i]);
22     for(register int i=1;i<=nq;i++){
23         scanf("%lld",&x);
24         if(x<stop) printf("%lld %lld\n",ans[x][1],ans[x][2]);
25         else if(x>=stop){
26             ac=(x-stop)%(n-1)+1;
27             //if(ac==0) ac=n-1;
28             printf("%lld %lld\n",maxx,a[stop+ac]);
29         }
30     }
31     return 0;
32 }
T2-B

T3

也是思维题,比较水

思路:光哥每次查房,咱们给他记录一个vis

 1 #include <bits/stdc++.h>
2 using namespace std;
3 bool ans[100010][4];
4 bool vis[100010];
5 int n,m,x;
6 long long trueans;
7 int main(){
8     scanf("%d%d",&n,&m);
9     trueans=4+3*(n-2);
10     for(register int i=1;i<=m;i++){
11         scanf("%d",&x),vis[x]=1;//2
12         if(vis[x+1]) ans[x+1][1]=1;
13         if(vis[x-1]) ans[x-1][3]=1;
14     }
15     for(register int i=1;i<=n;i++)
16     for(register int j=1;j<=3;j++) if(ans[i][j]) trueans--;
17     for(register int i=1;i<=n;i++) if(vis[i]) trueans--;
18     printf("%lld",trueans);
19     return 0;
20 }
T3-C

T4

难题,数学题

思路:我们给等式两边同时乘上a[i]-a[j]然后暴力即可.....

 1 #include <bits/stdc++.h>
2 using namespace std;
3 unsigned long long n,p,k;
4 unsigned long long a[3000010],b[3000010];
5 unsigned long long ans,c;
6 bool vis[3000010];
7 inline unsigned long long ksc(unsigned long long a,unsigned long long b,unsigned long long p){
8     unsigned long long ret=0;
9     while(b){
10         if(b&1) ret=(ret+a)%p;
11         a=(a+a)%p;
12         b>>=1;
13     }
14     return ret;
15 }
16 int main(){
17     scanf("%lld%lld%lld",&n,&p,&k);
18     for(register int i=1;i<=n;i++)
19     {
20         scanf("%lld",&a[i]);
21         a[i]=(a[i]*a[i]%p*a[i]%p*a[i]-k*a[i]%p+p)%p;
22     }
23     sort(a+1,a+n+1);
24     for(int i=1;i<n;i++)
25     {
26         if(a[i]==a[i+1])
27         {
28             c++;
29
30             ans+=c;
31         }
32         else
33         c=0;
34
35     }
36     printf("%lld",ans);
37     return 0;
38 }
T4-D

由于后面的问题涉及玄学~~~

Error 404! ! !

end;

posted @ 2019-07-30 19:49  Zafkiel  阅读(155)  评论(0编辑  收藏  举报
Live2D //博客园自带，可加可不加