結果
問題 | No.2649 [Cherry 6th Tune C] Anthem Flower |
ユーザー | GOTKAKO |
提出日時 | 2024-02-23 21:43:54 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 662 ms / 2,000 ms |
コード長 | 3,221 bytes |
コンパイル時間 | 2,440 ms |
コンパイル使用メモリ | 211,272 KB |
実行使用メモリ | 18,196 KB |
最終ジャッジ日時 | 2024-09-29 06:02:31 |
合計ジャッジ時間 | 9,218 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 505 ms
6,820 KB |
testcase_02 | AC | 496 ms
6,816 KB |
testcase_03 | AC | 497 ms
6,816 KB |
testcase_04 | AC | 501 ms
6,816 KB |
testcase_05 | AC | 662 ms
6,816 KB |
testcase_06 | AC | 659 ms
6,820 KB |
testcase_07 | AC | 35 ms
6,820 KB |
testcase_08 | AC | 35 ms
6,820 KB |
testcase_09 | AC | 8 ms
6,816 KB |
testcase_10 | AC | 9 ms
6,820 KB |
testcase_11 | AC | 2 ms
6,820 KB |
testcase_12 | AC | 2 ms
6,820 KB |
testcase_13 | AC | 38 ms
10,344 KB |
testcase_14 | AC | 39 ms
9,232 KB |
testcase_15 | AC | 37 ms
9,204 KB |
testcase_16 | AC | 37 ms
9,368 KB |
testcase_17 | AC | 39 ms
14,560 KB |
testcase_18 | AC | 36 ms
9,700 KB |
testcase_19 | AC | 37 ms
11,076 KB |
testcase_20 | AC | 39 ms
17,524 KB |
testcase_21 | AC | 39 ms
13,556 KB |
testcase_22 | AC | 40 ms
10,848 KB |
testcase_23 | AC | 39 ms
16,876 KB |
testcase_24 | AC | 40 ms
16,208 KB |
testcase_25 | AC | 39 ms
16,356 KB |
testcase_26 | AC | 41 ms
16,460 KB |
testcase_27 | AC | 40 ms
16,348 KB |
testcase_28 | AC | 41 ms
16,216 KB |
testcase_29 | AC | 41 ms
18,196 KB |
testcase_30 | AC | 41 ms
16,476 KB |
testcase_31 | AC | 40 ms
16,308 KB |
testcase_32 | AC | 40 ms
17,848 KB |
testcase_33 | AC | 41 ms
16,348 KB |
testcase_34 | AC | 436 ms
6,820 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; long long mod = 998244353; //入力が必ずmod未満の時に使う. struct mint{ long long v = 0; mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;} long long val(){return v;} void modu(){v %= mod;} mint repeat2mint(long long a,long long b){ mint ret = 1,p = a; int Log = 60; if(b <= 2e9) Log = 30; for(int i=0; i<Log; i++){if(b&(1LL<<i)) ret *= p; p *= p;} return ret; }; mint operator+(mint b){return (v+b.v)%mod;} mint operator-(mint b){return (v-b.v+mod)%mod;} mint operator*(mint b){return v*b.v%mod;} mint operator/(mint b){ if(b.v == 0) assert(false); return v*(repeat2mint(b.v,mod-2)).v%mod; } void operator+=(mint b){v = (v+b.v)%mod;} void operator-=(mint b){v = (v-b.v+mod)%mod;} void operator*=(mint b){v = v*b.v%mod;} void operator/=(mint b){ if(b.v == 0) assert(false); v = v*repeat2mint(b.v,mod-2).v%mod; } void operator++(int){v = (v+1)%mod; return;} void operator--(int){v = (v-1+mod)%mod; return;} bool operator==(mint b){if(v == b.v) return true; else return false;} bool operator!=(mint b){if(v != b.v) return true; else return false;} bool operator>(mint b){if(v > b.v) return true; else return false;} bool operator>=(mint b){if(v >= b.v) return true; else return false;} bool operator<(mint b){if(v < b.v) return true; else return false;} bool operator<=(mint b){if(v <= b.v) return true; else return false;} mint pow(long long x){return repeat2mint(v,x);} mint inv(){return mint(1)/v;} }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ string s; cin >> s; cin >> mod; reverse(s.begin(),s.end()); int N = s.size(); vector<long long> A,B; for(auto c : s) A.push_back((int)(c-'0')); A.push_back(0); B = A; B.at(0)++; for(int i=0; i<N; i++){ if(B.at(i) == 10) B.at(i) = 0,B.at(i+1)++; else break; } vector<long long> C; if(A.at(0)%2 == 0){ long long now = 0; for(int i=N-1; i>=0; i--){ long long c = 0; if(now) c = 5; if(A.at(i)%2) now = 1; else now = 0; c += A.at(i)/2; C.push_back(c); } reverse(C.begin(),C.end()); A = C; } else{ long long now = 0; for(int i=N; i>=0; i--){ long long c = 0; if(now) c = 5; if(B.at(i)%2) now = 1; else now = 0; c += B.at(i)/2; C.push_back(c); } reverse(C.begin(),C.end()); B = C; } vector<mint> p10(N+1,1); for(int i=1; i<=N; i++) p10.at(i) = p10.at(i-1)*10; mint a = 0,b = 0; for(int i=0; i<A.size(); i++) a += p10.at(i)*A.at(i); for(int i=0; i<B.size(); i++) b += p10.at(i)*B.at(i); cout << (a*b).v << endl; } }