結果
問題 | No.3106 Simple Math Problem 3 |
ユーザー |
|
提出日時 | 2025-04-11 21:33:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 1,607 bytes |
コンパイル時間 | 1,286 ms |
コンパイル使用メモリ | 161,396 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-04-11 21:33:18 |
合計ジャッジ時間 | 3,712 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long const int mod=998244353; mt19937 rnd; #define app push_back #define all(x) (x).begin(),(x).end() #ifdef LOCAL #define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__) #define debugv(v) do {cout<< #v <<" : {"; for(int izxc=0;izxc<v.size();++izxc) {cout << v[izxc];if(izxc+1!=v.size()) cout << ","; }cout <<"}"<< endl;} while(0) #else #define debug(...) #define debugv(v) #endif #define lob(a,x) lower_bound(all(a),x) #define upb(a,x) upper_bound(all(a),x) int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n;cin>>n; int res=0; /*for(int q=1;q<=n;++q) { int cnt=0; for(int b=q+1;b<=n;++b) { for(int p=q;p*b<=n-q;++p) { ++cnt; } } res+=q*cnt; } debug(res);*/ auto score=[&](int b,int p) { if(b*p>=n) return 0LL; int mq=min(b-1,p); mq=min(mq,n-b*p); //debug(b,p,mq); return (mq*(mq+1)/2)%mod; }; for(int p=1;p*p<=n;++p) { int l=p+1;int r=n/p-2; r=max(l,r); res+=score(l,p)*(r-l+1);res%=mod; res+=score(r+1,p);res%=mod; res+=score(r+2,p);res%=mod; res+=score(r+3,p);res%=mod; } for(int b=1;b*b<=n;++b) { int l=b;int r=n/b-2;r=max(l,r); res+=score(b,l)*(r-l+1);res%=mod; res+=score(b,r+1);res%=mod; res+=score(b,r+2);res%=mod; res+=score(b,r+3);res%=mod; } cout<<res; return 0; }