結果
| 問題 |
No.3304 INCREASE decrease
|
| コンテスト | |
| ユーザー |
pockyny
|
| 提出日時 | 2025-10-18 11:38:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 199 ms / 2,000 ms |
| コード長 | 1,054 bytes |
| コンパイル時間 | 1,006 ms |
| コンパイル使用メモリ | 86,660 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-18 11:39:00 |
| 合計ジャッジ時間 | 8,000 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
typedef long long ll;
// [l,r)の中の偶奇のcount
mint cnt(ll l,ll r,bool isEven){
if(l==0){
if(isEven) return r/2 + (r&1);
return r/2;
}
return cnt(0,r,isEven) - cnt(0,l,isEven);
}
mint nc2(mint x){return x*(x - 1)/2;}
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int t; cin >> t;
while(t){
t--;
ll i,n,k; cin >> n >> k;
ll ten = 1;
for(i=0;i<k;i++) ten *= 10;
mint ans = 0;
{
mint x = 0,y = 0;
for(i=0;i<2;i++) x += nc2(cnt(0,ten,i)) - nc2(cnt(n%ten,ten,i));
for(i=0;i<2;i++) y += nc2(cnt(0,n/ten + 1,i));
ans += x*y;
}
{
mint x = 0,y = 0;
for(i=0;i<2;i++) x += nc2(cnt(n%ten,ten,i));
for(i=0;i<2;i++) y += nc2(cnt(0,n/ten,i));
ans += x*y;
}
cout << ans.val() << "\n";
}
}
pockyny