#include<cstdio> #include<iostream> #include<cmath> #define mod (int)(1e9+7) using namespace std; int main() { int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); long long ans1 = (1+n)*n/2,ans2 = 1,ans3 = (1+n)*n/2; long long a1,a2,a3; int i,j; for(i = 1;i < n;i++) { a1 = n*(n-i)%mod; for(j = n-i-1;j > 0;j--) a1 -= j; a1 = a1*(int)pow(10,i)%mod; ans1 = (ans1+a1)%mod; } for(i = 1;i < n;i++) { a2 = (n-i)*(i+1)%mod; int k = 1; for(j = i+1;j > 0;j--) { if((n-i-k)==0) break; a2 = (a2-(n-i-k))%mod; k++; } a2 = a2*(int)pow(10,i)%mod; ans2 = (ans2+a2)%mod; } for(i = 1;i < n;i++) { a3 = (1+n-i)*(n-i)/2%mod; a3 = a3*(int)pow(10,i)%mod; ans3 = (ans3+a3)%mod; } printf("%lld %lld %lld\n",ans1,ans2,ans3); } return 0; }
先记录下。。因为还不会逆元。大数无法处理!!! 注意:这个不是AC代码
时间: 2024-10-13 01:47:46