以下代码过不了样例 2,但能 AC:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cassert>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define desktop "C:\\Users\\incra\\Desktop\\"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> PII;
const int dx[] = {1,0,-1,0},dy[] = {0,-1,0,1};
bool LAST = false;
istream& operator >> (istream& in,char* s) {
if (LAST) return in;
char ch = in.get ();
while ((isspace (ch) || ch == '\n') && ch != EOF) ch = in.get ();
int n = 0;
while (!(isspace (ch) || ch == '\n') && ch != EOF) s[n++] = ch,ch = in.get ();
s[n] = '\0';
if (ch == EOF) LAST = true;
return in;
}
template <typename T1,typename T2> bool tomax (T1 &x,T2 y) {
if (y > x) return x = y,true;
return false;
}
template <typename T1,typename T2> bool tomin (T1 &x,T2 y) {
if (y < x) return x = y,true;
return false;
}
LL power (LL a,LL b,LL p) {
LL ans = 1;
while (b) {
if (b & 1) ans = ans * a % p;
a = a * a % p;
b >>= 1;
}
return ans;
}
#define LL128 __int128
const int MOD = 19940417;
LL128 n,m;
LL128 sum1 (LL128 l,LL128 r,LL128 maxr = m) {
// if (l > maxr) return 0; 加了这句就能过样例2
tomin (r,maxr);
return (l + r) * (r - l + 1) / 2;
}
LL128 tmp_sum (LL128 x) {
return x * (x + 1) * (2 * x + 1) / 6;
}
LL128 sum2 (LL128 l,LL128 r) {
return tmp_sum (r) - tmp_sum (l - 1);
}
LL128 get1 (LL128 n,LL128 maxr) {
LL128 ans = 0;
for (LL128 l = 1;l <= n;) {
LL128 r = n / (n / l);
ans += (n / l) * sum1 (l,r,maxr);
l = r + 1;
}
return ans;
}
LL128 get2 (LL128 n,LL128 m) {
LL128 ans = 0;
for (LL128 l = 1;l <= n;) {
LL128 r = min (n / (n / l),m / (m / l));
ans += (n / l) * (m / l) * sum2 (l,r);
l = r + 1;
}
return ans;
}
int main () {
LL t1,t2;
cin >> t1 >> t2;
n = t1,m = t2;
if (n > m) swap (n,m);
cout << (LL)(((n * n - get1 (n,n)) * (m * m - get1 (m,m)) - (n * n * m - m * get1 (n,n) - n * get1 (m,n) + get2 (n,m))) % MOD) << endl;
return 0;
}