zoukankan      html  css  js  c++  java
  • 2016湖南省赛 A 2016 题解(同余)

    题目链接

    题目大意

    给出正整数 n 和 m,统计满足以下条件的正整数对 (a, b) 的数量:
    1<=a<=n 1<=b<=m a*b%2016=0

    题目思路

    我本来以为是容斥啥的,因为我写过一个类似的题目

    然而这个2016因子太多,完全不知怎么写

    其实很简单如果

    (i*j;mod;2016=0)

    ((i+k_1*2016)*(j+k_2*2016);mod;2016=0)

    代码

    #include<set>
    #include<map>
    #include<queue>
    #include<stack>
    #include<cmath>
    #include<cstdio>
    #include<vector>
    #include<string>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<unordered_map>
    #define fi first
    #define se second
    #define debug printf(" I am here
    ");
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int,int> pii;
    const ll INF=0x3f3f3f3f3f3f3f3f;
    const int maxn=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
    const double eps=1e-10;
    int n,m;
    signed main(){
        while(scanf("%d%d",&n,&m)!=-1){
            ll ans=0;
            for(int i=1;i<=2016;i++){   
                for(int j=1;j<=2016;j++){
                    if(i*j%2016==0&&n>=i&&m>=j){
                        ans+=1ll*(1+(n-i)/2016)*(1+(m-j)/2016);
                    }
                }
            }
            printf("%lld
    ",ans);
        }
        return 0;
    }
    
    
    卷也卷不过,躺又躺不平
  • 相关阅读:
    For-Each循环
    test
    网络学习一
    Struts2的interceptor
    Struts2的action解读
    js 读取<select>标签选项 索引
    java项目打jar包
    图解sendRedirect和forward的区别
    导入外部项目无法识别为Web项目无法部署到tomcat
    项目乱码的分析与解决
  • 原文地址:https://www.cnblogs.com/hunxuewangzi/p/13771165.html
Copyright © 2011-2022 走看看