結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー Nzt3
提出日時 2024-02-24 18:33:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 191,812 KB
最終ジャッジ日時 2025-02-19 21:10:53
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
void solve();
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_case;
  cin>>test_case;
  while (test_case--){
    solve();
  }
}
void solve(){
  string N;
  ll M;
  cin>>N>>M;
  M*=2;
  ll mN=0,t=1;
  for(int i=(int)N.size()-1;i>=0;i--){
    mN=(mN+(N[i]-'0')*t)%M;
    t=t*10%M;
  }
  cout<<mN*(mN+1)%M/2<<'\n';
}
0