Codeforces round #128 (Div. 2)

Source: Internet
Author: User
Tags acos cmath

Reprint please indicate the source, thank you http://blog.csdn.net/ACM_cxlove? Viewmode = contents by --- cxlove

A: Two Problems

Many people have planted very difficult questions. There are two questions: the initial score is A, the score is reduced by da per minute, and the initial score is B, and the database is reduced per minute. Ask if a person just gets x points.

X may be 0, which makes wa a lot of people, and x 0. This is certainly acceptable, and neither of the two questions is answered.

After that, the O (t) practice continued to be wa, speechless, and forced to directly attack O (T * t.

# Include <iostream> # include <iomanip> # include <cstdio> # include <cstring> # include <algorithm> # include <cstdlib> # include <cmath> # include <map> # include <stack> # include <set> # include <queue> # include <string> # include <vector> # define EPS 1e-6 # define ll long # define LD long double # define PI ACOs (-1.0) # define INF 1ll <60 using namespace STD; int flag [605]; int main () {int x, t, A, da, B, DB, I, j, AA, BB; scanf ("% d", & X, & T, & A, & B, & Da, & dB ); if (x = 0) puts ("yes"); else {for (I = 0; I <t; I ++) for (j = 0; j <t; j ++) {AA = A-I * Da; BB = B-J * dB; if (AA = x | BB = x | AA + BB = x) {puts ("yes"); Return 0 ;}} puts ("no");} return 0 ;}

B: Game on paper

It turns out that there were no evaluations in the end. The practice is to place a piece of chess, with the 9-palace lattice centered on the piece as the center to determine whether a 3*3 is formed. The maximum number of pawns is 10 W, and the maximum number of pawns is 10 W * 9*9. Note that the enumeration in main is in nine positions, which are held here at that time.

 # include 
  
    # include 
   
     # include 
    
      # include 
     
       # include 
      
        # include 
       
         # include 
        
          # include 
          # include 
          
            # include 
           
             # include 
            
              # include 
             
               # include 
              
                # define EPS 1e-6 # define ll long # define LD long double # define PI ACOs (-1.0) # define INF 1ll <60 using namespace STD; bool flag [1005] [1005]; int way [9] [2] ={{}, {-1, 0 },{}, {0,-1}, {}, {1,-1}, {-}, {-1,-1 }, {0, 0 }}; bool check (int x, int y) {If (flag [x] [Y] = false) return false; For (INT I = 0; I <8; I ++) if (flag [x + way [I] [0] [Y + way [I] [1] = false) return false; return true;} int main () {int n, m; while (scanf ("% d", & N, & M )! = EOF) {memset (flag, false, sizeof (FLAG); int X, Y; int ans =-1; for (int t = 1; t <= m; t ++) {scanf ("% d", & X, & Y); flag [x] [Y] = true; int I; If (ANS! =-1) continue; for (I = 0; I <9; I ++) {If (check (x + way [I] [0], Y + way [I] [1]) {ans = T; break ;}} printf ("% d \ n", ANS) ;}return 0 ;} 
              
             
            
           
          
        
       
      
     
    
   
  

 

C: photographer

Relatively simple and greedy. Customers with relatively small requirements can be satisfied first, and sorted in ascending order of total consumption.

 # include 
  
    # include 
   
     # include 
    
      # include 
     
       # include 
      
        # include 
       
         # include 
        
          # include 
          # include 
          
            # include 
           
             # include 
            
              # include 
             
               # include 
              
                # define EPS 1e-6 # define ll long # define LD long double # define PI ACOs (-1.0) # define INF 1ll <60 using namespace STD; int n, a, B, d; struct node {int X, Y; int cost; int ID X;} A [100005]; bool CMP (node N1, node N2) {return n1.cost 
               
                 = A [I]. cost) {ans [CNT ++] = A [I]. idx; D-= A [I]. cost;} elsebreak; printf ("% d \ n", CNT); If (CNT! = 0) {for (INT I = 0; I 
                
               
              
             
            
           
          
        
       
      
     
    
   
  

D: hit Ball

A messy explanation of the question. In a corridor, standing in (A/2, M, 0) without a vector (VX, Vy, VZ) throws a ball and asks where the ball finally hits the door. The door width is A, the door height is B, there is a wall on both sides of the corridor, there is a ceiling on the upper side, it will be reflected after the impact.

First, according to the y-axis direction, the component of the speed on the y-axis is always Vy, and is not changed by the impact. You can calculate the time-M/Vy;

Since each reflection does not change the speed component, it only changes the direction. For example, when it hits a wall and the speed changes from vx to-VX, the distance between the X axis direction motion can be calculated based on the known time, and then fold it into the range 0-.

# Include <iostream> # include <iomanip> # include <cstdio> # include <cstring> # include <algorithm> # include <cstdlib> # include <cmath> # include <map> # include <stack> # include <set> # include <queue> # include <string> # include <vector> # define EPS 1e-7 # define ll long # define LD long double # define PI ACOs (-1.0) # define INF 1ll <60 using namespace STD; int A, B, M; int VX, Vy, VZ; int main () {While (scanf ("% d", & A, & B, & M, & VX, & V Y, & VZ )! = EOF) {double T = m * (-1.0)/Vy; Double X = T * VX + A/2.0, ansx; If (x <EPS) {x =-X; int Cx = (INT) (X/a); ansx = x-cx * A; If (CX & 1) ansx = A-ansx ;} else if (x> A + EPS) {X-= A; int Cx = (INT) (X/a); ansx = x-cx * A; If (! (CX & 1) ansx = A-ansx;} elseansx = x; Double Z = T * VZ; int cz = (INT) (z/B ); double ansz = z-CZ * B; If (CZ & 1) ansz = B-ansz; printf ("%. 10f %. 10f \ n ", ansx, ansz);} return 0 ;}

E: readforces. You have time to read the questions. However, the English is really poor.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.