Submission #53671616
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;using ui = unsigned;using ll = long long;using ull = unsigned long long;using ld = long double;#define rep(i,l,r) for(int i=(l);i<=(r);++i)#define per(i,l,r) for(int i=(l);i>=(r);--i)#define repn(i,n) for(int i=0;i<(n);++i)#define sizc(x) ((int)x.size())#define allc(x) x.begin(),x.end()#define fir first#define sec secondtemplate <ui mod>class modint{ui val;static constexpr ui rd(ui x){return x<mod?x:x-mod;}public:modint(ll x=0){val=rd(x%mod+mod);}ui get()const{return val;}bool operator==(modint o)const{return val==o.val;}
#include <bits/stdc++.h> using namespace std; using ui = unsigned; using ll = long long; using ull = unsigned long long; using ld = long double; #define rep(i,l,r) for(int i=(l);i<=(r);++i) #define per(i,l,r) for(int i=(l);i>=(r);--i) #define repn(i,n) for(int i=0;i<(n);++i) #define sizc(x) ((int)x.size()) #define allc(x) x.begin(),x.end() #define fir first #define sec second template <ui mod> class modint{ ui val; static constexpr ui rd(ui x){return x<mod?x:x-mod;} public: modint(ll x=0){val=rd(x%mod+mod);} ui get()const{return val;} bool operator==(modint o)const{return val==o.val;} bool operator!=(modint o)const{return val!=o.val;} modint operator-()const{return mod-val;} modint &operator+=(modint o){val=rd(val+o.val);return *this;} modint &operator-=(modint o){val=rd(val+mod-o.val);return *this;} modint &operator*=(modint o){val=(ull)val*o.val%mod;return *this;} modint &operator/=(modint o){return *this*=o.inv();} modint &operator^=(ull o){modint res=1,x=*this;while(o){if(o&1)res*=x;x*=x;o>>=1;}return *this=res;} friend modint operator+(modint a,modint b){return a+=b;} friend modint operator-(modint a,modint b){return a-=b;} friend modint operator*(modint a,modint b){return a*=b;} friend modint operator/(modint a,modint b){return a/=b;} friend modint operator^(modint a,ull b){return a^=b;} modint &operator++(){return *this+=1;} modint &operator--(){return *this-=1;} modint operator++(int){modint ret=*this;++*this;return ret;} modint operator--(int){modint ret=*this;--*this;return ret;} friend istream &operator>>(istream &is,modint &a){return is>>a.val;} friend ostream &operator<<(ostream &os,modint a){return os<<a.val;} modint inv()const{return *this^mod-2;} }; namespace KnownError_{ using Z = modint<998244353>; Z count(int n){ return 9*(Z(10)^n-1); } Z sum(Z n){return n*(n+1)/2;} Z f(int a,int b){ if(a>b)return sum((Z(10)^b)-1); return sum((Z(10)^b)-1)-sum((Z(10)^b-1)-1); } void solve(){ int a,b,c; cin>>a>>b>>c; if(a<b)swap(a,b); if(c>a+1||c<a){cout<<"0\n";return;} Z cnta=count(a),cntb=count(b); Z ans=f(a,b)-f(a,b-1); if(a==c)ans=cnta*cntb-ans; cout<<ans<<'\n'; } void main(){ int T; cin>>T; while(T--)solve(); } } signed main(){ // freopen(".in","r",stdin); // freopen(".out","w",stdout); ios::sync_with_stdio(false); cin.tie(nullptr); KnownError_::main(); }
Submission Info
Submission Time | |
---|---|
Task | B - 1 + 6 = 7 |
User | KnownError_ |
Language | C++ 20 (gcc 12.2) |
Score | 600 |
Code Size | 2643 Byte |
Status | AC |
Exec Time | 115 ms |
Memory | 3532 KB |
Compile Error
Main.cpp: In function ‘KnownError_::Z KnownError_::count(int)’: Main.cpp:45:26: warning: suggest parentheses around arithmetic in operand of ‘^’ [-Wparentheses] 45 | return 9*(Z(10)^n-1); | ~^~ Main.cpp: In function ‘KnownError_::Z KnownError_::f(int, int)’: Main.cpp:50:45: warning: suggest parentheses around arithmetic in operand of ‘^’ [-Wparentheses] 50 | return sum((Z(10)^b)-1)-sum((Z(10)^b-1)-1); | ~^~ Main.cpp: In instantiation of ‘modint<mod> modint<mod>::inv() const [with unsigned int mod = 998244353]’: Main.cpp:27:50: required from ‘modint<mod>& modint<mod>::operator/=(modint<mod>) [with unsigned int mod = 998244353]’ Main.cpp:32:56: required from ‘modint<998244353> operator/(modint<998244353>, modint<998244353>)’ Main.cpp:47:31: required from here Main.cpp:40:39: warning: suggest parentheses around arithmetic in operand of ‘^’ [-Wparentheses] 40 | modint inv()const{return *this^mod-2;} | ~~~^~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 01-sample-01.txt |
All | 01-sample-01.txt, 02-min-01.txt, 03-max-01.txt, 04-rand-A-01.txt, 05-rand-B-01.txt, 06-rand-C-01.txt, 06-rand-C-02.txt, 06-rand-C-03.txt, 06-rand-C-04.txt, 07-near-01.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-sample-01.txt | AC | 1 ms | 3532 KB |
02-min-01.txt | AC | 12 ms | 3428 KB |
03-max-01.txt | AC | 20 ms | 3480 KB |
04-rand-A-01.txt | AC | 102 ms | 3340 KB |
05-rand-B-01.txt | AC | 19 ms | 3412 KB |
06-rand-C-01.txt | AC | 89 ms | 3456 KB |
06-rand-C-02.txt | AC | 89 ms | 3472 KB |
06-rand-C-03.txt | AC | 114 ms | 3336 KB |
06-rand-C-04.txt | AC | 115 ms | 3480 KB |
07-near-01.txt | AC | 34 ms | 3480 KB |