"Analog" "math" CSU 1803 2016 (2016 Hunan province 12th session of university students computer Program design Competition)

Source: Internet
Author: User
Tags cas

Topic Links:

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

Main topic:

Given N,m (n,m<=109) 1<=i<=n,1<=j<=m, the number of scenarios for i*j%2016=0 is obtained.

Topic Ideas:

"Analog" "math"

According to the remainder of the%2016 classification. Each additional 2016 is one more option. Statistics are several times 2016, sorted by the remainder. Finally, the remainder of the enumeration i,j can be solved.

1 //2 //by Coolxxx3 //#include <bits/stdc++.h>4#include <iostream>5#include <algorithm>6#include <string>7#include <iomanip>8#include <map>9#include <stack>Ten#include <queue> One#include <Set> A#include <bitset> -#include <memory.h> -#include <time.h> the#include <stdio.h> -#include <stdlib.h> -#include <string.h> - //#include <stdbool.h> +#include <math.h> - #defineMin (a) < (b) ( A):(B)) + #defineMax (a) (a) > (b)? ( A):(B)) A #defineABS (a) ((a) >0? ( A):(-(a))) at #defineLowbit (a) (a& (a)) - #defineSqr (a) ((a) * (a)) - #defineSwap (a) (a) ^= (b), (b) ^= (a), (a) ^= (b)) - #defineMem (A, B) memset (A,b,sizeof (a)) - #defineEPS (1E-8) - #defineJ 10000 in #defineMoD 1000000007 - #defineMAX 0x7f7f7f7f to #definePI 3.14159265358979323 + #defineN 2104 - using namespacestd; thetypedefLong LongLL; * intCas,cass; $ intN,m,lll,ans;Panax Notoginseng LL Aans; - intA[n],b[n]; the voidWorkintXintc[]) + { A     inti; thec[0]=x/ .; +      for(i=1; i<= (x .); i++) c[i]=c[0]+1; -      for(I= (x .)+1;i< .; i++) c[i]=c[0]; $ } $ intMain () - { - #ifndef Online_judge the //freopen ("1.txt", "R", stdin); - //freopen ("2.txt", "w", stdout);Wuyi     #endif the     inti,j,k; -      Wu //for (scanf ("%d", &cass); cass;cass--) - //for (scanf ("%d", &cas), cass=1;cass<=cas;cass++) About //while (~scanf ("%s", s+1)) $      while(~SCANF ("%d",&N)) -     { -scanf"%d",&m); -aans=0; A Work (n,a); + Work (m,b); the          for(i=0;i< .; i++) -              for(j=0;j< .; j + +) $                 if((i*j)% .==0) theaans+=1ll*a[i]*B[j]; theprintf"%lld\n", Aans); the     } the     return 0; - } in /* the // the  About // the */
View Code

"Analog" "math" CSU 1803 2016 (2016 Hunan province 12th session of university students computer Program design Competition)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.