• 2016


    1803: 2016

    Time Limit: 5 Sec     Memory Limit: 128 Mb     Submitted: 1506     Solved: 855    


     

    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

     

    Source

    湖南省第十二届大学生计算机程序设计竞赛

    //叉姐还是厉害啊,一道去年的省赛水题我想半年,还是太弱了!

    题解: 如果 a*b = 2016 那么,((a+2016) * b)%2016 = 0 (a * (b+2016)) %2016 = 0 所以找着规律再套一下数据,基本写出来就是必过的

     1 # include <cstdio>
     2 # include <cstring>
     3 # include <cstdlib>
     4 # include <iostream>
     5 # include <vector>
     6 # include <queue>
     7 # include <stack>
     8 # include <map>
     9 # include <bitset>
    10 # include <sstream>
    11 # include <set>
    12 # include <cmath>
    13 # include <algorithm>
    14 #pragma comment(linker,"/STACK:102400000,102400000")
    15 using namespace std;
    16 #define LL          long long
    17 #define lowbit(x)   ((x)&(-x))
    18 #define PI          acos(-1.0)
    19 #define INF         0x3f3f3f3f
    20 #define eps         1e-8
    21 #define MOD         1000000007
    22 
    23 inline int scan() {
    24     int x=0,f=1; char ch=getchar();
    25     while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    26     while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    27     return x*f;
    28 }
    29 inline void Out(int a) {
    30     if(a<0) {putchar('-'); a=-a;}
    31     if(a>=10) Out(a/10);
    32     putchar(a%10+'0');
    33 }
    34 #define MX 100005
    35 /**************************/
    36 LL a,b;
    37 int main()
    38 {
    39     LL num=0;
    40     for (int i=1;i<=2016;i++)
    41         for (int j=1;j<=2016;j++)
    42                 if (i*j%2016==0) num++;
    43 
    44     while (scanf("%lld%lld",&a,&b)!=EOF)
    45     {
    46         LL ca = a/2016;
    47         LL ya = a%2016;
    48         LL cb = b/2016;
    49         LL yb = b%2016;
    50         LL ans=0;
    51 
    52         ans += num*ca*cb;
    53 
    54         LL tp=0;
    55         for (int i=1;i<=ya;i++)
    56             for (int j=1;j<=2016;j++)
    57             if (i*j%2016==0) tp++;
    58         tp*=cb;
    59 
    60         for (int i=1;i<=ya;i++)
    61             for (int j=1;j<=yb;j++)
    62             if (i*j%2016==0) tp++;
    63         ans = tp+ans;
    64 
    65         tp=0;
    66         for (int i=1;i<=yb;i++)
    67             for (int j=1;j<=2016;j++)
    68             if (i*j%2016==0) tp++;
    69         tp*=ca;
    70 
    71         ans = tp+ans;
    72 
    73         printf("%lld
    ",ans);
    74     }
    75     return 0;
    76 }
    View Code

     

  • 相关阅读:
    适配器模式
    第五章项目:QuickHit
    试题分析(第二套)
    试题分析(第一套)
    新闻发布系统(分页显示)
    jsp九大内置对象
    文件上传
    jsp统测
    新闻发布系统(首页)
    URL和URI的区别
  • 原文地址:https://www.cnblogs.com/haoabcd2010/p/7354688.html
Copyright © 2020-2023  润新知