zoukankan      html  css  js  c++  java
  • 【模拟】【数学】CSU 1803 2016 (2016湖南省第十二届大学生计算机程序设计竞赛)

    题目链接:

      http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1803

    题目大意:

      给定n,m(n,m<=109)1<=i<=n,1<=j<=m,求i*j%2016=0的方案数。

    题目思路:

      【模拟】【数学】

      按照%2016的余数分类。每增加一个2016就又多一种方案。统计是2016的几倍,根据余数分类。最后枚举i,j的余数即可求解。

     1 //
     2 //by coolxxx
     3 //#include<bits/stdc++.h>
     4 #include<iostream>
     5 #include<algorithm>
     6 #include<string>
     7 #include<iomanip>
     8 #include<map>
     9 #include<stack>
    10 #include<queue>
    11 #include<set>
    12 #include<bitset>
    13 #include<memory.h>
    14 #include<time.h>
    15 #include<stdio.h>
    16 #include<stdlib.h>
    17 #include<string.h>
    18 //#include<stdbool.h>
    19 #include<math.h>
    20 #define min(a,b) ((a)<(b)?(a):(b))
    21 #define max(a,b) ((a)>(b)?(a):(b))
    22 #define abs(a) ((a)>0?(a):(-(a)))
    23 #define lowbit(a) (a&(-a))
    24 #define sqr(a) ((a)*(a))
    25 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
    26 #define mem(a,b) memset(a,b,sizeof(a))
    27 #define eps (1e-8)
    28 #define J 10000
    29 #define mod 1000000007
    30 #define MAX 0x7f7f7f7f
    31 #define PI 3.14159265358979323
    32 #define N 2104
    33 using namespace std;
    34 typedef long long LL;
    35 int cas,cass;
    36 int n,m,lll,ans;
    37 LL aans;
    38 int a[N],b[N];
    39 void work(int x,int c[])
    40 {
    41     int i;
    42     c[0]=x/2016;
    43     for(i=1;i<=(x%2016);i++)c[i]=c[0]+1;
    44     for(i=(x%2016)+1;i<2016;i++)c[i]=c[0];
    45 }
    46 int main()
    47 {
    48     #ifndef ONLINE_JUDGE
    49 //    freopen("1.txt","r",stdin);
    50 //    freopen("2.txt","w",stdout);
    51     #endif
    52     int i,j,k;
    53     
    54 //    for(scanf("%d",&cass);cass;cass--)
    55 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
    56 //    while(~scanf("%s",s+1))
    57     while(~scanf("%d",&n))
    58     {
    59         scanf("%d",&m);
    60         aans=0;
    61         work(n,a);
    62         work(m,b);
    63         for(i=0;i<2016;i++)
    64             for(j=0;j<2016;j++)
    65                 if((i*j)%2016==0)
    66                     aans+=1LL*a[i]*b[j];
    67         printf("%lld
    ",aans);
    68     }
    69     return 0;
    70 }
    71 /*
    72 //
    73 
    74 //
    75 */
    View Code
  • 相关阅读:
    POJO,简单的Java对象
    Oracle 11g R2 for Win7旗舰版(64位)- 安装
    Eclipse安装与配置
    Tomcat 安装、配置与部署
    图形数据库 Neo4j 开发实战【转载】
    Java 语言中 Enum 类型的使用介绍【转载】
    IBM Java 7 新特性和在 WAS 8.5 中的配置【转载】
    为Eclipse指定JVM
    网页页面的宽度:950 还是 960?
    Zabbix + Grafana
  • 原文地址:https://www.cnblogs.com/Coolxxx/p/5842420.html
Copyright © 2011-2022 走看看