此题有几个坑,首先,不能直接开10的9次方数组来做,其次中间变量的范围比long还要大,需要用到long long类型。此处我使用的map,因为map可以同时存下标和数字,同时map自带find函数,可以同时比较两个map数组中,是否有相同的下标,然后将数字取出相乘求和。#include <iostream>#include <map>using namespace std;int main(){ long n, a, b; cin >>.
此题有几个坑,首先,不能直接开10的9次方数组来做,其次中间变量的范围比long还要大,需要用到long long类型。此处我使用的map,因为map可以同时存下标和数字,同时map自带find函数,可以同时比较两个map数组中,是否有相同的下标,然后将数字取出相乘求和。#include <iostream>#include <map>using namespace std;int main(){ long n, a, b; cin >>.