結果
問題 | No.2649 [Cherry 6th Tune C] Anthem Flower |
ユーザー |
![]() |
提出日時 | 2024-02-23 21:50:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 360 ms / 2,000 ms |
コード長 | 483 bytes |
コンパイル時間 | 2,343 ms |
コンパイル使用メモリ | 245,768 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-29 06:14:25 |
合計ジャッジ時間 | 6,699 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;string N;ll M;void solve(){cin >> N >> M;reverse(N.begin(), N.end());ll p10 = 1;ll n = 0;for(char c : N){n = (n + (c - '0') * p10) % (2 * M);p10 = p10 * 10 % (2 * M);}ll ans = n * (n + 1) / 2 % M;cout << ans << endl;}int main(void){ios::sync_with_stdio(false);cin.tie(nullptr);int t; cin >> t;while(t--)solve();return 0;}