結果
問題 |
No.551 夏休みの思い出(2)
|
ユーザー |
|
提出日時 | 2025-04-25 22:16:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,408 bytes |
コンパイル時間 | 1,891 ms |
コンパイル使用メモリ | 192,464 KB |
実行使用メモリ | 16,068 KB |
最終ジャッジ日時 | 2025-04-25 22:16:46 |
合計ジャッジ時間 | 27,560 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 26 TLE * 2 -- * 19 |
ソースコード
#include <bits/stdc++.h> #define int long long namespace CZS_Office{ inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1; ch=getchar(); } while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*f; } inline void write(int x){ if(x<0){ putchar('-'); x=-x; } if(x>9)write(x/10); putchar(x%10+'0'); return; } } using namespace std; using namespace CZS_Office; int P,R,Q,a,b,c,res; inline int f(int x){return (a*(x*x%P))%P+(b*x)%P;} bool fft; //inline int pf(int x){return x*x;} //inline void solve(){ // int mx=P*P*a+P*b,res=(P-c)%P; // int ans[100005],cnt=0; // for(int i=0;i<=mx/P;++i){ // int C=-res-(i*P); // int deta=b*b-4*a*C; // if(pf(sqrtl(deta))!=deta)continue; // deta=sqrtl(deta); // if((-b+deta)%(2*a)==0) // ans[++cnt]=(-b+deta)/(2*a); // if((-b-deta)%(2*a)==0) // ans[++cnt]=(-b-deta)/(2*a); // } // sort(ans+1,ans+1+cnt);cnt=unique(ans+1,ans+1+cnt)-(ans+1); // int l=1; // while(l<=cnt&&ans[l]<0)++l; // while(l<=cnt&&ans[cnt]>=P)--cnt; // if(cnt-l+1<=0)write(-1); // else for(int i=l;i<=cnt;++i)write(ans[i]),putchar(' '); // putchar('\n');return; //} signed main(){ P=read();R=read();Q=read(); while(Q--){ a=read();b=read();c=read(); res=P-c;fft=0;res%=P; for(int i=0;i<P;++i){if(((a*(i*i%P))%P+(b*i)%P)%P==res){fft=1;write(i);putchar(' ');}} if(!fft)write(-1); putchar('\n'); } return 0; }