点击跳转例题
思路:首先我们看到图的时候,可以发现,正方形可以分为很多板块,和不同的形状,那么我们用乘法原理和加法原理求解即可。
#include <bits/stdc++.h> #define int long long //(有超时风险) #define PII pair<int,int> #define endl '\n' #define LL __int128 using namespace std; const int N=2e5+10,M=1e3+10,mod=1e9+7,INF=0x3f3f3f3f; int a[N],b[N],c[N],pre[N]; signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n;cin>>n; int ans=0; for(int i=1;i<n;i++) { //分块的个数*正方体形状的个数。 int tmp=(n-i)*(n-i)*i; ans=(ans+tmp)%mod; } cout<<ans<<endl; return 0; }
10-31
7502
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-12
7831
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-20
6473
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交