zoukankan      html  css  js  c++  java
  • FZU

    先上题目:

    Problem 1601 Alibaba's treasures

    Accept: 332    Submit: 636
    Time Limit: 1000 mSec    Memory Limit : 32768 KB

     Problem Description

    In the story of “Alibaba and forty robbers”, Alibaba uses his clever wit to overcome the ferocious enemy, and inherits the huge treasure. There are many treasures which is the rectangular net made by pearls, using silver strand to connect each other. Alibaba would like to cut some number of silver strand to make a pearl necklace. Your question is, given the size of pearls net, can Alibaba cut some of silver strand without wasting a pearl to make a pearl necklace(you can wear it in your neck)?

     Input

    The first line is a positive number C (C <= 1000), which is the number of test data. The following C lines, each line has two positive integers, M, N, represent the pearls net’s height and width respectively, the two integer are separated by a space. (1 <= M <= 1000, 1 <= N <= 1000).

     Output

    If we can cut some of silver strand without wasting a pearl to make a pearl necklace, output “Yes”, otherwise output “No”.

     Sample Input

    2
    1 1
    4 6

     Sample Output

    No
    Yes

     Hint

    There is a way to cut the net when M=4 and N=6.

      题意:给你一个n*m的矩阵,分成n*m个小正方形,问能不能从一个边和边的交点出发,每个交点经过一次,最终回到起点。

      找规律,只要有一条边是偶数的时候就可以满足条件,除非另一条边是1,只要有一条边是1的话那就不可以形成回路。

    上代码:

     1 #include <cstdio>
     2 
     3 using namespace std;
     4 
     5 int main()
     6 {
     7     int n,a,b,s;
     8     //freopen("data.txt","r",stdin);
     9     scanf("%d",&n);
    10     while(n--){
    11         scanf("%d %d",&a,&b);
    12         s=a*b;
    13         if(s%2==0 && a!=1 && b!=1) printf("Yes
    ");
    14         else printf("No
    ");
    15     }
    16     return 0;
    17 }
    1601
  • 相关阅读:
    使用PuTTY时的文件上传下载方法
    [emacs org-mode小技巧] org-indent-mode 让文档更容易阅读
    tldr 的安卓客户端
    如何配置ssh免密码登录
    降低屏幕亮度,减缓眼疲劳 (linux/windows/firefox/android)
    Android上面安装Linux的方法
    Spring中argNames的含义
    js 输出 select 的值
    js 优先级
    layer.confirm( 找不到 on函数
  • 原文地址:https://www.cnblogs.com/sineatos/p/3564994.html
Copyright © 2011-2022 走看看