zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    OpenGL Pixel Linked-List
    Unity multi_compile
    Bindless Textures
    chmod递归设置文件属性
    push submodule
    NodeJS Debugger
    重载new操作符
    OpenGL瓶颈
    NGUI架构和Draw Call合并原理
    字符串哈希函数(String Hash Functions)
  • 原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13806416.html
Copyright © 2011-2022 走看看