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