結果
問題 | No.2649 [Cherry 6th Tune C] Anthem Flower |
ユーザー |
|
提出日時 | 2024-02-24 01:49:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 114 ms / 2,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 1,624 ms |
コンパイル使用メモリ | 167,936 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-29 09:45:32 |
合計ジャッジ時間 | 4,349 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define REP(i,n) for(ll i=0;i<ll(n);i++) ll M; ll f(string S){ int n=S.size(); ll r=0; for(int i=0;i<n;i++){ r=(10*r+S[i]-'0')%M; } return r; } int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll i,j; int T; cin >> T; while(T--){ string N; cin >> N >> M; M*=2; ll x=f(N); cout << (x*(x+1)%M)/2 << '\n'; } return 0; }