2017 Multi-University Training Contest - Team 7 (hdu 6121 6124 6127 6129 6130)

hdu 6121

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 
 5 ll hh(ll x){
 6     if(x%4==1) return 1;
 7     else if(x%4==2) return x+1;
 8     else if(x%4==3) return 0;
 9     else return x;
10 }
11 
12 int main(){
13     int t;
14     cin>>t;
15     while(t--){
16         ll n,k;
17         cin>>n>>k;
18         if(k==1){
19             printf("%lld\n",hh(n));continue;
20         }
21         ll sum=1;
22         ll a=0,b=0,c=0;
23         ll s=k;
24         ll flag=0;
25         while(sum<=n-s){
26             sum=sum+s;
27             if((double)s>1e18/(double)k){
28                 flag=1;
29                 break;
30             }
31             s=s*k;
32         }
33         ll sheng=n-sum;
34         if(flag==0) s/=k;//倒数第二层个数//
35         a=sheng/k;
36         b=sheng%k==0?0:1;
37         c=s-a-b;
38         ll ans=sheng%2;
39         ll vala=k+1,valb;
40         if(sheng%k!=0) valb=sheng%k+1;
41         else valb=0;
42         ll valc=1;
43         while(a+b+c>1){
44             if(a%2==1) ans^=vala;
45             if(b%2==1) ans^=valb;
46             if(c%2==1) ans^=valc;
47             if(a%k!=0){
48                 valb=valb+vala*(a%k)+(k-b-a%k)*valc+1;
49                 b=1;
50             }
51             else valb=valb+(k-1)*valc+1;
52             a=a/k;vala=vala*k+1;
53             if(c%k!=0) b=1;
54             c=(c-c%k)/k;
55             valc=valc*k+1;
56         }
57         printf("%lld\n",ans^n);
58     }
59     return 0;
60 }
61 /*
62 2
63 5 2
64 */

hdu 6124

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main(){
 5     int t;
 6     cin>>t;
 7     while(t--){
 8         int n;
 9         cin>>n;
10         cout<<(n+1)/2+1<<endl;
11     }
12     return 0;
13 }

hdu 6127

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const double pi=acos(-1.0);
 5 const int N=100004;
 6 
 7 struct node{
 8     int x,y;
 9     int val;
10     double jd;
11 }a[N*2];
12 
13 double hh(node b){
14     double x=abs(b.x);
15     double y=abs(b.y);
16     if(b.x>0&&b.y>0) return atan(y/x)*180*1.0/pi;
17     else if(b.x<0&&b.y>0) return 180*1.0-atan(y/x)*180*1.0/pi;
18     else if(b.x<0&&b.y<0) return 180*1.0+atan(y/x)*180*1.0/pi;
19     else if(b.x>0&&b.y<0) return 360*1.0-atan(y/x)*180*1.0/pi;
20     else if(x==0&&b.y>0) return 90;
21     else if(x==0&&b.y<0) return 270;
22     else if(y==0&&b.x>0) return 0;
23     else if(y==0&&b.x<0) return 180;
24 }
25 
26 bool cmp(node p,node q){
27     return p.jd<q.jd;
28 }
29 int main(){
30     int t;
31     cin>>t;
32     while(t--){
33         int n;
34         ll sum=0;
35         scanf("%d",&n);
36         for(int i=1;i<=n;i++){
37             scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].val);
38             a[i].jd=hh(a[i]);
39             sum+=a[i].val;
40         }
41         sort(a+1,a+1+n,cmp);
42         for(int i=n+1;i<=2*n;i++){
43             a[i]=a[i-n];
44             a[i].jd+=360;
45         }
46         ll s1=0,s2=0;
47         int l=1,r;
48         for(int i=1;i<=n;i++){
49             if(a[i].jd-a[1].jd<180) s1+=a[i].val;
50             else {
51                 r=i;break;
52             }
53         }
54         s2=sum-s1;
55         ll ans=0;
56         while(l<=n){
57             ans=max(ans,s1*s2);
58             s1-=a[l].val;s2+=a[l].val;
59             l++;
60             while(r<=2*n&&a[r].jd-a[l].jd<180){
61                 s1+=a[r].val;
62                 s2-=a[r].val;
63                 r++;
64             }
65         }
66         cout<<ans<<endl;
67     }
68     return 0;
69 }
70 /*
71 2
72 2
73 1 1 1
74 1 -1 1
75 3
76 1 1 1
77 1 -1 10
78 -1 0 100
79 */
80 /*
81 1
82 1100
83 */

 

hdu 6129

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const int N=200005;
 4 typedef long long ll;
 5 
 6 ll a[N],b[N];
 7 
 8 
 9 int main(){
10     int t ;
11     cin>>t;
12     while(t--){
13         int n,m;
14         memset(b,0,sizeof(b));
15         scanf("%d%d",&n,&m);
16         for(int i=1;i<=n;i++) scanf("%d",&a[i]);
17         for(int i=1;i<=n;i++){
18             int y=i-1;
19             int x=i+m-2;
20             if((x&y)==y){
21                 int k=1;
22                 for(int j=i;j<=n;j++) {
23 
24                     b[j]^=a[k++];
25                 }
26                
27             }
28         }
29         for(int i=1;i<=n;i++){
30             printf("%d",b[i]);
31             if(i!=n) printf(" ");
32             else printf("\n");
33         }
34         
35     }
36 }

hdu 6130

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int a[10000005];
 5 
 6 void init(){
 7     a[1]=1,a[2]=2,a[3]=2;
 8     int x=1,y=3;
 9     int l=3;
10     while(l<=10000004){
11         for(int i=1;i<=a[y];i++)
12             a[++l]=x;
13         if(x==2) x=1;
14         else x=2;
15         y++;
16     }
17 }
18 int main(){
19     int t;
20     init();
21     cin>>t;
22     while(t--){
23         int n;
24         scanf("%d",&n);
25         cout<<a[n]<<endl;
26     }
27 }

 

posted on 2017-08-16 11:48  hhhhx  阅读(125)  评论(0编辑  收藏  举报

导航