Codeforces Round #276 (Div. 2)

Source: Internet
Author: User

Codeforces Round #276 (Div. 2)
A. Factorytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there wereXDetails in the factory storage, then by the end of the day the factory has to produce (remainder after dividingXByM) More details. Unfortunately, no customer has ever bought any mythical detail, so all the details produced stay on the factory.

The board of directors are worried that the production by the given plan may eventually injection · modules "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> modules + YTwvZW0 + signature + bTwvZW0 + signature + h3D88ZW0 + YTwvZW0 + LD88ZW0 + bTwvZW0 + P6HcPzEwPHN1cCBjbGFzcz0 = "upper-index"> 5 ).

Output

Print "Yes" (without quotes) if the production will eventually stop, otherwise print "No ".

¼ Ò µ¥ì â


#include   #include 
  
     #include 
   
      #include 
    
       #include 
     
        #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include using namespace std;int main(){int a, m;while (~scanf("%d%d", &a, &m)){map
           
             qu;qu.clear();bool flag = false;while(1){a = a + a % m;a %= m;if (a == 0){flag = true;break;}if (qu[a]){break;}else{qu[a] = 1;}}if (flag){printf("Yes\n");}else{printf("No\n");}}return 0;}
           
          
         
        
       
      
     
    
   
  

B. Valuable Resourcestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Compute computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems.

Let's suppose that your task is to build a square city. the world map uses the Cartesian coordinates. the sides of the city shocould be parallel to coordinate axes. the map contains mines with valuable resources, located at some points with integer coordinates. the sizes of mines are relatively small, I. e. they can be treated as points. the city shoshould be built in such a way that all the mines are inside or on the border of the city square.

Building a city takes large amount of money depending on the size of the city, so you have to build the city with the minimum area. given the positions of the mines find the minimum possible area of the city.

Input

The first line of the input contains numberNToo many the number of mines on the map (2? ¡U?N? ¡U? 1000). Each of the nextNLines contains a pair of integersXIAndYIPlease specify the coordinates of the corresponding mine (? -? 109? ¡U?XI,?YI? ¡U? 109). All points are pairwise distinct.

Output

Print the minimum area of the city that can cover all the mines with valuable resources.

Sample test (s) Input
20 02 2
Output
4
Input
20 00 3
Output
9

¼ Ò µ¥ì â


#include   #include 
  
     #include 
   
      #include 
    
       #include 
     
        #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include using namespace std;struct node{int x, y;}pp[1010];int cmp1(node a, node b){return a.x < b.x;}int cmp2(node a, node b){return a.y < b.y;}int main(){int n;while (~scanf("%d", &n)){for (int i = 0; i < n; ++i){scanf("%d%d", &pp[i].x, &pp[i].y);}int l, r, u, d;sort(pp, pp + n, cmp1);l = pp[0].x;r = pp[n - 1].x;sort(pp, pp + n, cmp2);d = pp[0].y;u = pp[n - 1].y;__int64 a = (__int64)max(r - l, u - d);printf("%I64d\n", a * a );}return 0;}
          
         
        
       
      
     
    
   
  

C. Bitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Let's denote as the number of bits set ("1 'bits) in the binary representation of the non-negative integerX.

You are given multiple queries consisting of pairs of integersLAndR. For each query, findX, Such thatL? ¡U?X? ¡U?R, And is maximum possible. If there are multiple such numbers find the smallest of them.

Input

The first line contains integerNPlease specify the number of queries (1? ¡U?N? ¡U? 10000 ).

Each of the followingNLines contain two integersLI,?RICannot parse the arguments for the corresponding query (0? ¡U?LI? ¡U?RI? ¡U? 1018 ).

Output

For each query print the answer in a separate line.

Sample test (s) Input
31 22 41 10
Output
137

Please refer to the zookeeper. Then, you can see the zookeeper in the United States. limit 2 ^ n-1 â n ù µäê £ £ ************************************************ please visit £». N. Then, please refer to the following link for more information, B £;° ü ° ¬ Õ â ¸ öçø ä ä£;;;» ° ó à Ó ó Ò Ô 2 µµ µ C £;;â» ° ó Å ¶ Ï Ó Ç çø ä äzää ø Ï µ£%%%%%%%%%%%%%%%%%%%%%%%%%*%c + B/2, · añomantíóró A + C/2 £;ö± µ~~úço ~äú£;****§ {{± á{£. ¬ Ì ù  úâ ë


#include   #include 
  
     #include 
   
      #include 
    
       #include 
     
        #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include using namespace std;__int64 l, r;__int64 a[70];int main(){int n;__int64 li, ri, mid, lii, rii;a[0] = 1;for (int i = 1; i <= 59; ++i){a[i] = a[i - 1] << 1;a[i]++;}scanf("%d", &n);while(n--){scanf("%I64d%I64d", &l, &r);if (l == r){printf("%I64d\n", r);continue;}bool flag = false;for (int i = 59; i >= 0; --i){if (a[i] >= l && a[i] <= r){printf("%I64d\n", a[i]);flag = true;break;}}if (flag){continue;}for (int i = 0; i <= 59; ++i){if (a[i] > r){ri = rii = a[i];break;}}for (int i = 59; i >= 0; --i){if (a[i] < l){li = lii = a[i];break;}}while (1){mid = (li + ri) >> 1;if (mid < l){li = mid;ri = rii;}else if(mid > r){ri = mid;li = lii;}else{printf("%I64d\n", mid);break;}}}return 0;}
          
         
        
       
      
     
    
   
  


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.