zoukankan      html  css  js  c++  java
  • 2016 湖南省省赛 Problem A: 2016

    Problem A: 2016

    Time Limit: 5 Sec  Memory Limit: 128 MB
    Submit: 296  Solved: 171

    Description

     给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量:
    1. 1≤a≤n,1≤b≤m;
    2. a×b 是 2016 的倍数。
     

    Input

    输入包含不超过 30 组数据。
    每组数据包含两个整数 n,m (1≤n,m≤109).

    Output

    对于每组数据,输出一个整数表示满足条件的数量。

    Sample Input

    32 63
    2016 2016
    1000000000 1000000000
    

    Sample Output

    1
    30576
    7523146895502644
    

    HINT

    /*
    真心菜,就水出来一个题......
    任何一个数都能表示成n=a*2016+i,m=b*2016+j;
    n*m=a*b*2016^2+a*2016*j+b*2016*i+i*j;
    如果i*j是2016的倍数的话,那么n*m一定是2016的倍数,
    这样在2016*2016的规模中遍历出符合i*j%2016=0的数,按照n中有多少个这样的i,m中有多少这样的j,然后相乘,累加起来就得到的区间中所有的数
    */
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #define MAXN 2016
    using namespace std;
    int main()
    {
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
        long long cur=0;
        long long n,m;
        while(scanf("%lld%lld",&n,&m)!=EOF)
        {
            cur=0;
            for(int i=1;i<=min((long long )2016,n);i++)
            {
                for(int j=1;j<=min((long long )2016,m);j++)
                {
                    if((i*j)%2016==0)
                    {
                        //cout<<i<<" "<<j<<endl;
                        cur+=((n-i)/2016+1)*((m-j)/2016+1);
                    }
                }
            }
            printf("%lld
    ",cur);
        }
        return 0;
    }
    /*
                       _ooOoo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      O  =  /O
                   ____/`---'\____
                 .'  \|     |//  `.
                /  \|||  :  |||//  
               /  _||||| -:- |||||-  
               |   | \  -  /// |   |
               | \_|  ''---/''  |   |
                 .-\__  `-`  ___/-. /
             ___`. .'  /--.--  `. . __
          ."" '<  `.___\_<|>_/___.'  >'"".
         | | :  `- \`.;` _ /`;.`/ - ` : | |
            `-.   \_ __ /__ _/   .-` /  /
    ======`-.____`-.___\_____/___.-`____.-'======
                       `=---='
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             I have a dream!A AC deram!!
     orz orz orz orz orz orz orz orz orz orz orz
     orz orz orz orz orz orz orz orz orz orz orz
     orz orz orz orz orz orz orz orz orz orz orz
    
    */
  • 相关阅读:
    【PyQt5-Qt Designer】QSpinBox-微调框
    【PyQt5-Qt Designer】QProgressBar() 进度条
    【PyQt5-Qt Designer】QSlider滑块
    Tomcat eclipse 启动时一个工程影响另一个工程
    apache thrift 和 apache jersey 记录
    常用 Linux 命令
    mac 命令记录
    eclipse m2eclipse 从Maven的本地库中读取依赖库
    成功build Maven但eclipse中依然显示该工程有错误
    mac install: /usr/bin/unrar: Operation not permitted
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/5838984.html
Copyright © 2011-2022 走看看