代码
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 100010;
const int mod = 1000000007;
int a[N],b[N];
//总结: 记得开 long long
/*题目中的65是指:1 * 1 + 2 * 2 + 3 * 2 * 10 = 65;
两数相减取最小进制位,每一位的最小进制位为a和b该位上的数字的最大值加1和2进行比较,选最大的
保证满足进制的要求
*/
int main(){
int n,ma,mb;
cin >> n;
cin >> ma;
for(int i = 1; i <= ma; i++) cin >>a[i];
cin >> mb;
for(int i = 1; i <= mb;i++) cin >> b[i];
reverse(a + 1, a + ma + 1);
reverse(b + 1, b + mb + 1);
long long w = 1;
long long ans = 0;
for(int i = 1; i <= ma || i <= mb; i++){
int tpw = max(max(a[i],b[i]) + 1, 2);
ans = (ans + (a[i] - b[i]) * w % mod);
ans = (ans + mod) % mod;
w = w * tpw % mod;
}
cout << ans;
return 0;
}
标签:ma,进制,mb,4404,cin,long,int,减法
From: https://www.cnblogs.com/index-12/p/17280002.html