Codeforces #200 (div.2) simulated exercise Competition

Source: Internet
Author: User

Codeforces #200 (div.2) simulated exercise Competition
Question A: How many ideas can A magnet be divided into when the same-sex magnet excludes each other? Read and calculate while reading and adding 1 when reading something different from the previous one (the first group of data is specially judged) I did not clarify my thinking and try again, but I was too full of = _ + than my teammates. Code:

#include 
  
   #include
   #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        
         #include 
         
          #include 
          
           #include 
           
            #include using namespace std;typedef long long int LL;const int M = 100009,INF = 0x3fffffff;int main(void) { //problem: cf#200, address: int n, y, last = -1, ans = 1; string x; cin >> n; while(n--) { cin >> x; if(x == "10") y = 10; else y = 1; if(last != -1 && y != last) ans++; last = y; } cout << ans << endl; return 0;}
           
          
         
        
       
      
     
    
  
Question B: given three atomic numbers (A, B, C), each atom has A chemical price, indicating the number of chemical bonds to be connected to other atoms (however, the figure is not good, misleading A lot of time) solution: as long as you know the number of chemical bonds between A and B atoms X , The number of atoms of the other two edges can contain X And then check whether it meets the atomic price requirements. Code:
#include 
  
   #include
   #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        
         #include 
         
          #include 
          
           #include 
           
            #include using namespace std;typedef long long int LL;const int M = 100009,INF = 0x3fffffff;int main(void) { //problem:cf#200 , address: int a, b, c; cin >> a >> b >> c; bool ok = false; for(int i = 0; i <= b; i++) { if(b - i == c - (a - i)) { ok = true; cout << i << " " << b - i << " "<< a - i << endl; break; } } if(!ok) cout << "Impossible" << endl; return 0;}
           
          
         
        
       
      
     
    
  
Question C: given an unlimited unit resistance, each operation can give the current circuit parallel or concatenate a unit resistance to reach the target resistance (in the form of a false score) the minimum number of operations required for resistance. Idea: the idea is to start from a unit of resistance and search for the minimum number of Target solutions with breadth first, however, the exponential size of the forward solution space of 2 must be a queue or time-out. Then we decided to roll back from the answer to the initial state, obviously reducing the space size. Sometimes it is a good idea to start from the target solution, which can greatly reduce the solution space. This idea was used in question A of the weekly competition in the afternoon and was successfully implemented. Note: In this question, the long data is used. However, the long data used for calculation in the middle of the two data I read is still int and WA. Code:
#include 
  
   #include
   #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        
         #include 
         
          #include 
          
           #include 
           
            #include using namespace std;typedef long long int LL;const int M = 100009,INF = 0x3fffffff;LL a, b, ans;void dfs(LL x, LL y) { if(y == 0) return; ans += x / y; x %= y; swap(x, y); dfs(x, y);}int main(void) { //problem: cf#200, address: cin >> a >> b; dfs(a, b); cout << ans << endl; return 0;}
           
          
         
        
       
      
     
    
  
D: Question: Can I solve the Winding Rope? Idea: as long as the two connected overwrites are the same line, the two overwrites can be directly eliminated. In this way, it is easy to use a stack to read and simulate. Code:
#include 
  
   #include
   #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        
         #include 
         
          #include 
          
           #include 
           
            #include using namespace std;typedef long long int LL;const int M = 100009,INF = 0x3fffffff;int main(void) { //problem: , address: char c; stack
            
              s; while ((c = getchar()) != '\n') { int x = (c == '+' ? 1 : -1); if(s.empty()) {s.push(x); continue;} if(x == s.top()) s.pop(); else s.push(x); } cout << (s.empty() ? "Yes" : "No") << endl; return 0;}
            
           
          
         
        
       
      
     
    
  
Conclusion: grasp code details and train thinking skills.

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.