提出 #42233535
ソースコード 拡げる
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<ctime>
using namespace std;
typedef long long LL;
inline void zwap(LL &x,LL &y){x^=y^=x^=y;}
LL mod;
inline LL ksm(LL x,LL y){
LL ans=1;
while(y){
if(y&1)ans=ans*x%mod;
x=x*x%mod;y>>=1;
}
return ans;
}
LL n;
inline LL ni(LL x){return ksm(x,mod-2);}
int main(){
srand(999);
int T;scanf("%d",&T);
while(T--){
scanf("%lld%lld",&n,&mod);
while(1){
LL x=rand()%(mod-1)+1,y=rand()%(mod-1)+1,z=rand()%(mod-1)+1;
if(x==y || y==z || x==z)continue;
LL nx=ksm(x,n),ny=ksm(y,n),nz=ksm(z,n);
LL s1=(x+y+z)%mod,s2=(nx+ny+nz)%mod,s3=(nx*nx+ny*ny+nz*nz)%mod;
if(!s1 || !s2 || !s3)continue;
LL s4=(nx*nx%mod*nx+ny*ny%mod*ny+nz*nz%mod*nz)%mod;
if(!s4)continue;
LL ns=ni(s4);
LL t=ns*s1%mod*s2%mod*s3%mod;
t=ni(t);
LL ax=t*x%mod,ay=t*y%mod,az=t*z%mod;
if(ax>ay)zwap(ax,ay);
if(ay>az)zwap(ay,az);
if(ax>ay)zwap(ax,ay);
printf("%lld %lld %lld\n",ax,ay,az);
break;
}
}
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
D - Equation |
| ユーザ |
juruozjj |
| 言語 |
C++ (GCC 9.2.1) |
| 得点 |
800 |
| コード長 |
1052 Byte |
| 結果 |
AC |
| 実行時間 |
314 ms |
| メモリ |
3176 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:22:13: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
22 | int T;scanf("%d",&T);
| ~~~~~^~~~~~~~~
./Main.cpp:24:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
24 | scanf("%lld%lld",&n,&mod);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
800 / 800 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
01_sample_01.txt |
| All |
01_sample_01.txt, 02_small_01.txt, 02_small_02.txt, 03_rand_1_01.txt, 03_rand_1_02.txt, 04_rand_2_01.txt, 04_rand_2_02.txt, 05_max_1_01.txt, 06_max_2_01.txt, 07_max_3_01.txt, 08_p_minus_one_01.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 01_sample_01.txt |
AC |
5 ms |
1652 KiB |
| 02_small_01.txt |
AC |
153 ms |
1700 KiB |
| 02_small_02.txt |
AC |
159 ms |
1688 KiB |
| 03_rand_1_01.txt |
AC |
293 ms |
3116 KiB |
| 03_rand_1_02.txt |
AC |
293 ms |
3080 KiB |
| 04_rand_2_01.txt |
AC |
244 ms |
1656 KiB |
| 04_rand_2_02.txt |
AC |
247 ms |
1676 KiB |
| 05_max_1_01.txt |
AC |
303 ms |
3176 KiB |
| 06_max_2_01.txt |
AC |
314 ms |
1660 KiB |
| 07_max_3_01.txt |
AC |
314 ms |
3148 KiB |
| 08_p_minus_one_01.txt |
AC |
287 ms |
3088 KiB |