The 12th session of Hunan Province College students computer Program design competition problem A 2016

Source: Internet
Author: User

If a * b% 2016 = = 0

If a = 1, and a * b% 2016 = = 0

Consider a = 2017.

* B = (+ 1) * b% 2016 = = 0 must be established

So that means the b,2017 in 1 can be paired with the same.

Same: 4033 * b = (+ + 1) * b% 2016 = = 0 must be established

So, I can enumerate [1,2016] in [1,2016], I * j% 2016 = = 0 of the logarithm, and then multiply on the corresponding [1,n] in the number of I, instead of the number is also counted, the substitution number is those equivalent number, 1------4033

#include <cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<algorithm>using namespacestd;#defineINF (0X3F3F3F3F)typedefLong Long intLL; #include<iostream>#include<sstream>#include<vector>#include<Set>#include<map>#include<queue>#include<string>LL N, m;Const intMAXN = .+ -; LL NUMN[MAXN], NUMM[MAXN];voidWork () {LL TNK= N/ .; LL RN= n% .; memset (Numn,0,sizeofnumn); memset (Numm,0,sizeofNumm);  for(inti =1; I <= RN; ++i) {Numn[i]= TNK +1; }    for(inti = rn +1; I <= .; ++i) {Numn[i]=TNK; } LL TMK= m/ .; LL RM= m% .;  for(inti =1; I <= RM; ++i) {Numm[i]= TMK +1; }    for(inti = RM +1; I <= .; ++i) {Numm[i]=TMK; } LL ans=0;  for(inti =1; I <= .; ++i) { for(intj =1; J <= .; ++j) {if((i * j)% .==0) {ans+ = numn[i] *Numm[j]; } }} cout<< ans <<Endl;}intMain () {#ifdef local freopen ("Data.txt","R", stdin);#endif     while(Cin >> N >>m) {work (); }    return 0;}
View Code

The 12th session of Hunan Province College students computer Program design competition problem A 2016

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.