十进制 10^n-1=n个9 *9的逆元 n个1 *q %mod
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
ll T;
ll n,m,minn,maxx;
ll q;
ll pow_mod(ll a,ll b){
ll res=1;
while(b){
if(b&1)
res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
ll inv_mod(ll a,ll mod){
return pow_mod(a,mod-2);
}
int main(){
cin>>n>>q;
ll ans=( (pow_mod(10,n)-1) * inv_mod(9,mod)%mod*q)%mod;
cout<<ans<<endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
ll T;
ll n,m,minn,maxx,cnt,sum;
ll q,a[maxn];
ll pow_mod(ll a,ll b){
ll res=1;
while(b){
if(b&1)
res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
}
cout<<pow_mod(2,n-1)*sum %mod<<endl;
return 0;
}
n<=1e5
2e5会超时 加速
st说1e6以上加速输入
i i+1 n-1个
1 2
2 3
3 4
1 3
1 4
2 4
1和除2外的其他
3-n + 1个 2 n
int main(){
IO;
cin>>n;
for(int i=1;i<=n-1;i++){
cout<<i<<" "<<i+1<<endl;
}
for(int i=3;i<=n;i++){
cout<<1<<" "<<i<<endl;
}
cout<<2<<" "<<n<<endl;
return 0;
}