美团笔试整除7
//保存num[i]%7 和10^i%7 由xy%7=((x%7)*(10^k%7)+y%7)%7;
#include<iostream>
#include<vector>
#include<math.h>
#include<string>
using namespace std;
int main(){
int n, temp;
cin >> n;
vector<int> num;
vector<int> wei;
vector<int> flag;
for (int i = 0; i<n; i++){
cin >> temp;
num.push_back(temp);
wei.push_back(to_string(temp).length());
flag.push_back(temp % 7);
}
vector<int> ss;
for (int i = 0; i <= 9; i++) ss.push_back(int(pow(10.0, i)) % 7);
int res = 0;
for (int i = 0; i<n; i++){
for (int j = i + 1; j<n; j++){
if (flag[i]==0 && flag[j]==0){ res += 2; continue; }
else{ if (flag[i]==0 || flag[j]==0) continue; }
int num1 = flag[i] * ss[wei[j]] + flag[j];
int num2 = flag[j] * ss[wei[i]] + flag[i];
if (num1 % 7 == 0) res++;
if (num2 % 7 == 0) res++;
}
}
cout << res << endl;
return 0;
}