• 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
    
    */
  • 相关阅读:
    dell r720服务器raid5安装centos6.5系统
    centos6.5报错:checking filesystems failed问题处理
    配置mysql5.5主从复制、半同步复制、主主复制
    vmware下centos克隆功能对网络的设置
    mysql报错问题解决MySQL server PID file could not be found!
    使用第三方工具Xtrabackup进行MySQL备份
    mysql数据库基于LVM快照的备份
    mysql的日志及利用mysqldump备份及还原
    centos6.5下java和tomcat环境部署
    通达OA数据库优化方案之_历史数据清理
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/5838984.html
Copyright © 2020-2023  润新知