当前位置:网站首页>[training Day6] game [mathematics]
[training Day6] game [mathematics]
2022-07-24 20:10:00 【VL——MOESR】

Ideas :
We found the formula that can directly list the answers :
a n s = ∑ i = 1 n ∑ j = 1 m H i ∗ L j ∗ ( m ∗ ( i − 1 ) + j ) ans=\sum_{i=1}^{n}\sum_{j=1}^{m}H_i*L_j*(m*(i-1)+j) ans=i=1∑nj=1∑mHi∗Lj∗(m∗(i−1)+j)
among H and L Represents the multiple of row and column expansion
Just row , delimit O(n+m) The formula that can be worked out is ok ( Row by yourself )
c o d e code code
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const ll MAXN = 1e6 + 10;
const ll mod = 1e9 + 7;
ll n, m, k;
ll l[MAXN], h[MAXN];
int main() {
freopen("game.in", "r", stdin);
freopen("game.out", "w", stdout);
scanf("%lld%lld%lld", &n, &m, &k);
for(ll i = 1; i <= m; i ++) l[i] = 1;
for(ll i = 1; i <= n; i ++) h[i] = 1;
for(ll i = 1; i <= k; i ++) {
char ch; ll x, y;
cin>>ch>>x>>y;
if(ch == 'R') h[x] *= y, h[x] %= mod;
else l[x] *= y, l[x] %= mod;
}
ll sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
for(ll i = 1; i <= n; i ++) {
sum2 = (sum2 + (i - 1) * m % mod * h[i] % mod) % mod;
sum3 = (sum3 + h[i]) % mod;
}
for(ll i = 1; i <= m; i ++) {
sum1 = (sum1 + l[i]) % mod;
sum4 = (sum4 + i * l[i] % mod) % mod;
}
printf("%lld", (sum1 * sum2 % mod + sum3 * sum4 % mod) % mod);
}
边栏推荐
- Leetcode 146: LRU cache
- Talk about your transformation test development process
- Are network security and data security indistinguishable? Why is data security important?
- Framework API online viewing source code
- Risk control system, implemented by flink+clickhouse!
- Apache atlas version 2.2 installation
- Understand the domestic open source Magnolia license series agreement in simple terms
- Basic idea of regularization
- 存储类别
- Redis common configuration description
猜你喜欢
![Leetcode 300 longest increasing subsequence (greedy + binary search for the first element subscript smaller than nums[i]), leetcode 200 island number (deep search), leetcode 494 target sum (DFS backtr](/img/60/6b75484a65a49c6e20c2b79c062310.png)
Leetcode 300 longest increasing subsequence (greedy + binary search for the first element subscript smaller than nums[i]), leetcode 200 island number (deep search), leetcode 494 target sum (DFS backtr

从服务器批量下载文件到本地

Istio II traffic hijacking process

Make Huawei router into FTP server (realize upload and download function)

Unity2d~ game practice of decrypting Zhou mu (completed in three days)

Talk about your transformation test development process

01 | opening words: teach you to build a blog website hand in hand

Look at the interface control devaxpress WinForms - how to customize auxiliary function properties (Part 2)

Flink window & time principle

Analysis and Simulation of strlen function
随机推荐
Lights of thousands of families in the year of xinchou
Setting up a dual machine debugging environment for drive development (vs2017)
Write a batch and start redis
《自尊的6大支柱》自尊来源于自身的感受
Inconsistent time
[trial experience of Yuxin micro Wiota ad hoc network protocol development kit] RT thread BSP Software package production
Safe way -- Analysis of single pipe reverse connection back door
Review the code implementation of memcpy function
Sword finger offer 53 - I. find the number I in the sorted array
The beginning of winter in the year of bitterness and ugliness
Create a life cycle aware MVP architecture
Look at the interface control devaxpress WinForms - how to customize auxiliary function properties (Part 2)
Unity3d eventsystem (event)
Redis basic knowledge, application scenarios, cluster installation
Work notes - some problems encountered when using jest
How to select the shelling tool?
Redis common configuration description
The U.S. economy continues to be weak, and Microsoft has frozen recruitment: the cloud business and security software departments have become the hardest hit
Framework API online viewing source code
Apache atlas version 2.2 installation