• Pair (pairs)


    Description


    The children are playing a matching game. There are (n) boys and (m) girls, numbered (1 sim n) and (1 sim m) respectively. If the sum of the numbers of boy (i) and girl (j) is a multiple of 5, they are called a reasonable one pair. Program a reasonable total number of pairs.

    Format


    Input

    The first line is a positive integer (t(≤100)), which represents the number of data sets;
    the next (t) line, each line contains two positive integers (n) and (m) ((1≤n, m ≤10^8)), which represent the number of boys and girls, respectively.

    Output

    For each set of data, output a reasonable total number of pairs.

    Sample


    Input

    2
    6 12
    21 21
    

    Output

    14
    88
    

    Sample Code


    #include <cstdio>
    typedef long long ll;
    int main(){
        freopen("pairs.in", "r", stdin);
        freopen("pairs.out", "w", stdout);
        int t, n, m;
        scanf("%d", &t);
        while (t--){
            scanf("%d %d", &n, &m);
            /*ll ans=0;
            for (int i=1; i<=n; i++)
                ans+=m/5+((m%5+i%5)>=5);
                //ans+=(i+m)/5-i/5;
            cout<<ans<<endl;*/
            
            ll x=n/5, y=m/5;
            int u=n%5, v=m%5;
            ll ans=x*y*5+u*y+v*x+((u+v)>4?u+v-4:0);
            printf("%lld
    ", ans);
        }
        return 0;
    }
    
  • 相关阅读:
    Js 30 BOM
    js面向对象
    js模态窗口
    js默认行为(也称默认事件)
    框架的控件隐藏
    20150706 js之定时器
    sublime快捷方式和node.js
    js回调函数2
    Hibernate 多对一
    Hibernate入门之配置文件
  • 原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13806416.html
Copyright © 2020-2023  润新知