提出 #74685854
ソースコード 拡げる
#include <bits/stdc++.h>
using ull = unsigned long long int;
using ll = long long int;
using lll = __int128;
using namespace std;
const int mod = 998244353;
int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
inline string sread() {
string s;
char ch = getchar();
// 跳过空白字符
while (ch == ' ' || ch == '\n' || ch == '\r') ch = getchar();
// 读取非空白字符
while (ch != ' ' && ch != '\n' && ch != '\r' && ch != EOF) {
s += ch;
ch = getchar();
}
return s;
}
ll read(){
ll k = 0,f = 1;
char c = getchar();
while(c < '0' || c > '9')
{
if(c == '-')f = -1;
c = getchar();
}
while(c >= '0' && c <= '9')k = k * 10 + c - '0',c = getchar();
return k * f; // 别忘记标记的负数要乘进去
}
// 调用时用 n = in();
void print(ll x){
if(x < 0)putchar('-'),x = -x;
if(x < 10)putchar(x + '0');
else print(x / 10),putchar(x % 10 + '0');
}
// 直接调用 out(n) 就行了
ll ksm(ll base, ll e){
ll res = 1;
while(e){
if(e & 1){
res = res * base % mod;
}
base = base * base % mod;
e >>= 1;
}
return res;
}//ksm板子
vector<vector<ll>> matrix_mul (vector<vector<ll>>& a, vector<vector<ll>>& b) {
int l1 = a.size(), l2 = b[0].size();
vector<vector<ll>>res(l1, vector<ll>(l2, 0));
for(int i = 0; i < l1; i++){
for(int k = 0; k < a[0].size(); k++){
if(a[i][k]){
for(int j = 0; j < l2; j++){
res[i][j] = (res[i][j] + a[i][k] * b[k][j]);
}
}
}
}
return res;
}// 矩阵a * 矩阵b(矩阵乘法)
void Solve(){
ll n = read(), m = read();
vector<ll>a(n + 1), b(m + 1);
for(int i = 1; i <= n; i++)a[i] = read();
for(int j = 1; j <= m; j++)b[j] = read();
ll sumb = 0;
for(int j = 1; j <= m; j++) sumb = (sumb + b[j]) % mod;
ll iai = 0;
for(int i = 1; i <= n; i++){
iai = (iai + 1LL * i * a[i] % mod) % mod;
}
vector<ll>prea(n + 1);
for(int i = 1; i <= n; i++){
prea[i] = (prea[i - 1] + a[i]) % mod;
}
ll s = 0;
for(int j = 1; j <= m; j++){
ll cur = 0;
for(int q = 1; q <= n / j; q++){
cur = (cur + q * ((prea[min(1LL * (q + 1) * j - 1, n)] - prea[q * j - 1]) % mod + mod) % mod) % mod;
}
s = (s + b[j] * j % mod * cur % mod) % mod;
}
cout << ((sumb * iai % mod - s) % mod + mod) % mod;
}
signed main(){
int T = 1;
while(T--){
Solve();
}
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function 'std::vector<std::vector<long long int> > matrix_mul(std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&)':
./Main.cpp:53:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int k = 0; k < a[0].size(); k++){
| ~~^~~~~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
450 / 450 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00-sample-01.txt, 00-sample-02.txt |
| All |
00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00-sample-01.txt |
AC |
1 ms |
3392 KiB |
| 00-sample-02.txt |
AC |
1 ms |
3488 KiB |
| 01-01.txt |
AC |
1 ms |
3448 KiB |
| 01-02.txt |
AC |
1 ms |
3568 KiB |
| 01-03.txt |
AC |
1 ms |
3544 KiB |
| 01-04.txt |
AC |
1 ms |
3700 KiB |
| 01-05.txt |
AC |
1 ms |
3616 KiB |
| 01-06.txt |
AC |
1 ms |
3556 KiB |
| 01-07.txt |
AC |
1 ms |
3616 KiB |
| 01-08.txt |
AC |
1 ms |
3672 KiB |
| 01-09.txt |
AC |
65 ms |
15076 KiB |
| 01-10.txt |
AC |
64 ms |
14924 KiB |
| 01-11.txt |
AC |
17 ms |
7224 KiB |
| 01-12.txt |
AC |
17 ms |
7104 KiB |
| 01-13.txt |
AC |
17 ms |
7156 KiB |
| 01-14.txt |
AC |
23 ms |
8436 KiB |
| 01-15.txt |
AC |
65 ms |
14912 KiB |
| 01-16.txt |
AC |
65 ms |
14956 KiB |
| 01-17.txt |
AC |
64 ms |
14964 KiB |
| 01-18.txt |
AC |
64 ms |
14956 KiB |
| 01-19.txt |
AC |
20 ms |
10944 KiB |
| 01-20.txt |
AC |
49 ms |
11700 KiB |