結果
問題 |
No.2207 pCr検査
|
ユーザー |
|
提出日時 | 2023-02-15 18:22:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 326 ms / 3,000 ms |
コード長 | 988 bytes |
コンパイル時間 | 1,691 ms |
コンパイル使用メモリ | 192,368 KB |
最終ジャッジ日時 | 2025-02-10 15:42:36 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:19: warning: ‘m’ may be used uninitialized [-Wmaybe-uninitialized] 32 | for(int i=0; i<m; ++i){ | ~^~ main.cpp:19:15: note: ‘m’ was declared here 19 | int res=1,m; | ^
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; using pii=pair<int,int>; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int maxn=10000005,mod=998244853; int mul(int x, int y){return ((ll)x)*y%mod;} int Pow(int x, int y=mod-2){int res=1; for(; y; x=mul(x,x),y>>=1) if(y&1) res=mul(res,x); return res;} int inv[maxn]; signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); inv[1]=1; for(int i=2; i<maxn; ++i) inv[i]=mul(inv[mod%i],mod-mod/i); int res=1,m; int k; cin >> k; for(int i=0; i<k; ++i){ int p,x; cin >> p >> x; res=mul(res,Pow(p,x)); if(i==k-1){ m=p; if(x>1){ cout << "-1 -1\n"; return 0; } } } for(int i=0; i<m; ++i){ if(res==1){ cout << m << ' ' << i << "\n"; return 0; } res=mul(res,mul(inv[m-i],i+1)); } cout << "-1 -1\n"; }