Solution:
考虑两个数x,y乘积%2016=0
x×y≡0(MOD 2016)
x=p1×2016+q1
y=p2×2016+q2
x×y=(p1×2016+q1)×(p2×2016+q2)=2016^2×p1p2+2016(p1q2+q1p2)+p1p2≡0(MOD 2016)
实际上就转化为余数乘积取模=0,预处理没两个余数乘积是否mod2016=0
统计答案两个余数出现的个数相乘即可(注意特判0不能选)
复杂度:O(2016^2)
// <1803.cpp> - Wed Oct 19 08:25:53 2016// This file is made by YJinpeng,created by XuYike's black technology automatically.// Copyright (C) 2016 ChangJun High School, Inc.// I don't know what this program is.#include#include #include #include #include #include #include #define MOD 2016#define src(x,n) (n/MOD+(x!=0?(n%MOD>=x):0))using namespace std;typedef long long LL;vector >a;int main(){ freopen("1803.in","r",stdin); freopen("1803.out","w",stdout); for(int i=0;i