【類比】【數學】CSU 1803 2016 (2016湖南省第十二屆大學生電腦程式設計競賽)

來源:互聯網
上載者:User

標籤:

題目連結:

  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 1000029 #define mod 100000000730 #define MAX 0x7f7f7f7f31 #define PI 3.1415926535897932332 #define N 210433 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_JUDGE49 //    freopen("1.txt","r",stdin);50 //    freopen("2.txt","w",stdout);51     #endif52     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\n",aans);68     }69     return 0;70 }71 /*72 //73 74 //75 */
View Code

 

【類比】【數學】CSU 1803 2016 (2016湖南省第十二屆大學生電腦程式設計競賽)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.