2019 Jiamusi training Day7

    T1

  Math is not very water, difficulty in

  Ideas: First, we found that in addition 2xy than the rest of the sum must be odd

Then we find no solution r is an even number, and r <= 4 when no solution, the remainder is the case

3+ an even, clearly express all cases, the direct output, and 1 (r-3) / 2 to

  
1 #include <bits/stdc++.h>
2 using namespace std;
3 long long r;
4 int main(){
5     scanf("%lld",&r);
6     if(r%2==0||r<=5) printf("NO");
7     else printf("1 %lld",(r-3)/2);
8     return 0;
9 }
T1- sign problem

    T2

  Garbage problem, smelly title, the title can give the wrong side !!! (A or I'll go up in smoke)

  Ideas: violence simulation run on the line, need to pay attention, the squad leader position in any case will not go 0

Therefore, once the monitor is changed to 1 to 0 to go.

  
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int n,m,k,t,x,y,l,r;
 4 int main(){
 5     scanf("%d%d%d%d",&n,&m,&k,&t);
 6     for(register int i=1;i<=t;i++){
 7         scanf("%d%d",&x,&y);
 8         if(x==0){
 9             if(y<=m){
10                 m-=y;
11                 n-=y;
12             }
13             else if(y>m){
14                 n-=(n-y);
15             }
16         }
17         if(x==1){
18             if(y<=m){
19                 n++,m++;
20             }
21             if(y>m) n++;
22         }
23         if(m==0) m=1;
24         printf("%d %d\n",n,m);
25     }
26     return 0;
27 }
T2- power

    T3

  We sometimes need easy violence, to solve the problem of violence

  Ideas: we pretreated the horizontal and vertical kept well apart, and violence run O (n ^ 3)

Every enumeration two sides sideways, then traversed one by one the rest of the vertical side, if you can cut two vertical side

Transverse edges, to a cumulative num, finish each one vertical side, ans + = num * (num-1) / 2 can be;

  
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 struct node{
 4     int yu,yd,x;
 5 }shu[1010];
 6 struct nodee{
 7     int xl,xr,y;
 8 }heng[1010];
 9 int he,sh;
10 int n,a,b,c,d,num;
11 long long ans;
12 int main(){
13     scanf("%d",&n);
14     for(register int i=1;i<=n;i++){
15         scanf("%d%d%d%d",&a,&b,&c,&d);
16         if(a==c){
17             sh++;
18             shu[sh].x=a;
19             shu[sh].yu=max(b,d);
20             shu[sh].yd=min(b,d);
21             continue;
22         }
23         he++;
24         heng[he].y=b;
25         heng[he].xr=max(a,c);
26         heng[he].xl=min(a,c);
27     }
28     for(register int i=1;i<=he;i++){
29         for(register int j=i+1;j<=he;j++){
30             num=0;
31             int emm=max(heng[i].y,heng[j].y);
32             int err=min(heng[i].y,heng[j].y);
33             int ess=max(heng[i].xl,heng[j].xl);
34             int epp=min(heng[i].xr,heng[j].xr);
35             if(epp<=ess)continue;
36             for(register int k=1;k<=sh;k++){
37                 if(shu[k].yu>=emm&&shu[k].yd<=err&&shu[k].x>=ess&&shu[k].x<=epp) num++;
38             }
39             ans+=num*(num-1)/2;
40         }
41     }
42     printf("%lld",ans);
43     return 0;
44 }
T3- rectangle

 

  end;

Guess you like

Origin www.cnblogs.com/liuhailin/p/11291213.html