zoukankan      html  css  js  c++  java
  • Desktop(模拟)2016-2017 ACM Central Region of Russia Quarterfinal Programming Contest

    Vasily is a college student who likes to keep everything in order. One of his hobbies is software. Yesterday he installed a new operating system Windows 999999. The key difference between the new system and Windows XP is that Windows 999999 has 999,999 pre-installed utilities and after the installation of the system, the desktop is absolutely empty. Vasily wants to place the maximum number of shortcuts to the utilities on his desktop. His computer screen is a grid sized h × w and the icons are squares sized 2 × 2. Icons must be positioned so that their corners match the borders of grid cells. They can also overlap each other, so the bottom icon will be partly covered by the top one. For comfort, Vasily decided that at least half of an icon (2 cells) must be visible; otherwise it would be hard to click on it. Now Vasily wants to know the maximum number of icons that can be placed on his desktop and the appropriate positioning pattern.

    Limitations

    1 ≤ h, w ≤ 500

    Input

    The first line in the input file contains two integer numbers h and w , representing the height and the width of Vasily’s computer screen.

    Output

    The first line in the output file must contain the number N – the maximum number of icons that can be fitted on Vasily’s desktop considering the conditions listed above. If N>0, the next N lines must contain pairs of numbers representing the coordinates of the upper right corners of the icons (line number and column number). The icons will be placed in the same order as they are listed, so each subsequent icon might lap over some of the previously listed icons.

    Examples

    Input.txt

    2 4

    Output.txt

    3

    1 1

    1 2

    1 3

    模拟题,Wa了十四边,最后才知道,坐标是从下往上从0开始的

     1 #include <stdio.h>
     2 
     3 int main()
     4 {
     5     freopen("input.txt", "r", stdin);
     6     freopen("output.txt", "w", stdout);
     7     int n, m, i, j;
     8     scanf("%d %d", &n, &m);
     9     if(n<2||m<2)
    10     {
    11         printf("0
    ");
    12     }
    13     else
    14     {
    15         printf("%d
    ", n*m/2-1);
    16         if(n%2==1)
    17         {
    18             for(i=m-1; i-1>=0; i-=2)
    19             {
    20                 printf("%d %d
    ", 1, i);
    21             }
    22         }
    23         for(i=n-1; i-1>=0; i-=2)
    24         {
    25             for(j=m-1; j-2>=0; j--)
    26             {
    27                 printf("%d %d
    ", i, j);
    28             }
    29         }
    30 
    31         for(i=n-1; i-1>=0; i--)
    32         {
    33             if(i-2<0&&n%2==1) break;
    34             printf("%d %d
    ", i, 1);
    35         }
    36 
    37     }
    38     return 0;
    39 }
  • 相关阅读:
    bs4解析错误之 bs4 FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.
    UI自动化之selenium元素定位不到问题的原因有哪几种?
    selenium定位:出现Message: element not interactable 元素不可交互的问题解决方案
    JS--编码规范
    JS操作数组-2
    JS-数组操作3
    JS操作数组
    用JS解决url地址中参数乱码的问题
    数组去重--ES5和ES6
    选择排序
  • 原文地址:https://www.cnblogs.com/0xiaoyu/p/11341800.html
Copyright © 2011-2022 走看看