zoukankan      html  css  js  c++  java
  • HDU 1792 A New Change Problem(数学规律题,数论知识)

    A New Change Problem

    Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 533    Accepted Submission(s): 265


    Problem Description
    Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1.Here you can assume that there are enough coins for both kinds.Please calculate the maximal value that you cannot pay and the total number that you cannot pay.
     
    Input
    The input will consist of a series of pairs of integers A and B, separated by a space, one pair of integers per line.
     
    Output
    For each pair of input integers A and B you should output the the maximal value that you cannot pay and the total number that you cannot pay, and with one line of output for each line in input.
     
    Sample Input
    2 3 3 4
     
    Sample Output
    1 1 5 3
     
    Author
    lcy
     
    Recommend
    lcy
     
     
    题目就是给了两个互质的数A,B。
    A*x+B*y(x>=0,y>=0)
    问最大不能表示的数,和不能表示的数的个数。
     
    数论知识;
    个数就是(A-1)*(B-1)/2;
    最大不能表示的数就是 A*B-A-B;
     
    所有的数可以分成A类,就是对A取模余0~A-1的。
    ·······
     
    代码:
    #include<stdio.h>
    int main()
    {
    int A,B;
    while(scanf("%d%d",&A,&B)!=EOF)
    {
    printf("%d %d\n",A*B-A-B,(A-1)*(B-1)/2);
    }
    return 0;
    }
  • 相关阅读:
    Java String字符串补0或空格
    oracle查看当前用户权限
    plsql developer 导出导入存储过程和函数
    扩展jQuery easyui datagrid增加动态改变列编辑的类型
    jQueryEasyUI Messager基本使用
    combox源码解析
    Solr -- Solr Facet 2
    Solr -- Solr Facet 1
    nginx -- 安装配置Nginx
    DOS
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2433881.html
Copyright © 2011-2022 走看看