Submission #52480700
Source Code Expand
// LUOGU_RID: 156203043
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=300+5,M=2000+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-8;const int INF=1e9+7;mt19937 rnd(181766);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
ll a,b,c;
void Solve(){
int i,j;scanf("%lld%lld%lld",&a,&b,&c);
a=b-a;c=c-b;
if(!a&&!c){puts("1");return;}
if(!a||!c){puts("2");return;}
if(a==c){puts("5");return;}
ll g=__gcd(a,c);a/=g;c/=g;
ll f=1,g1=0,g2=0,ans=(a+c)*2;
if(a<c) swap(a,c);
while(c){
ll t=a/c%mod;a%=c;swap(a,c);t-=!c;
ll g3=g1;g1=g2;g2=(f*t+(mod-g3)*(t-1))%mod;gdb(ans,t,g1,g2,f,g1,g2,g3);
ans+=(t*(t+1)/2%mod*f%mod-t*(t-1)/2%mod*g3%mod)*2;
if(!c) ans-=(f*t+(mod-g3)*(t-1))*2%mod;
f=(f*(t+1)+(mod-g3)*t)%mod;
if(!c) ans+=f;
}
printf("%lld\n",(ans%mod+1+mod)%mod);
}
int main(){
int t=1;
scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Submission Info
| Submission Time |
|
| Task |
F - Reflection |
| User |
fangxintong |
| Language |
C++ 20 (gcc 12.2) |
| Score |
1800 |
| Code Size |
1676 Byte |
| Status |
AC |
| Exec Time |
185 ms |
| Memory |
4016 KiB |
Compile Error
Main.cpp: In function ‘void Solve()’:
Main.cpp:30:13: warning: unused variable ‘i’ [-Wunused-variable]
30 | int i,j;scanf("%lld%lld%lld",&a,&b,&c);
| ^
Main.cpp:30:15: warning: unused variable ‘j’ [-Wunused-variable]
30 | int i,j;scanf("%lld%lld%lld",&a,&b,&c);
| ^
Main.cpp:30:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | int i,j;scanf("%lld%lld%lld",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function ‘int main()’:
Main.cpp:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d",&t);
| ~~~~~^~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
1800 / 1800 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
01_sample_01.txt |
| All |
01_sample_01.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 03_rand_1_01.txt, 03_rand_1_02.txt, 03_rand_1_03.txt, 03_rand_1_04.txt, 03_rand_1_05.txt, 03_rand_1_06.txt, 03_rand_1_07.txt, 03_rand_1_08.txt, 03_rand_1_09.txt, 03_rand_1_10.txt, 04_rand_2_01.txt, 04_rand_2_02.txt, 04_rand_2_03.txt, 04_rand_2_04.txt, 04_rand_2_05.txt, 04_rand_2_06.txt, 04_rand_2_07.txt, 04_rand_2_08.txt, 04_rand_2_09.txt, 04_rand_2_10.txt, 05_rand_3_01.txt, 05_rand_3_02.txt, 05_rand_3_03.txt, 05_rand_3_04.txt, 05_rand_3_05.txt, 05_rand_3_06.txt, 05_rand_3_07.txt, 05_rand_3_08.txt, 05_rand_3_09.txt, 05_rand_3_10.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 01_sample_01.txt |
AC |
1 ms |
3960 KiB |
| 02_small_01.txt |
AC |
34 ms |
4016 KiB |
| 02_small_02.txt |
AC |
33 ms |
3984 KiB |
| 02_small_03.txt |
AC |
34 ms |
3896 KiB |
| 02_small_04.txt |
AC |
34 ms |
4016 KiB |
| 02_small_05.txt |
AC |
33 ms |
3864 KiB |
| 02_small_06.txt |
AC |
33 ms |
3896 KiB |
| 02_small_07.txt |
AC |
33 ms |
3900 KiB |
| 02_small_08.txt |
AC |
33 ms |
3972 KiB |
| 02_small_09.txt |
AC |
33 ms |
3800 KiB |
| 02_small_10.txt |
AC |
33 ms |
3864 KiB |
| 03_rand_1_01.txt |
AC |
119 ms |
3808 KiB |
| 03_rand_1_02.txt |
AC |
120 ms |
3968 KiB |
| 03_rand_1_03.txt |
AC |
120 ms |
3984 KiB |
| 03_rand_1_04.txt |
AC |
119 ms |
3872 KiB |
| 03_rand_1_05.txt |
AC |
120 ms |
3892 KiB |
| 03_rand_1_06.txt |
AC |
120 ms |
3856 KiB |
| 03_rand_1_07.txt |
AC |
120 ms |
3956 KiB |
| 03_rand_1_08.txt |
AC |
119 ms |
3884 KiB |
| 03_rand_1_09.txt |
AC |
119 ms |
3956 KiB |
| 03_rand_1_10.txt |
AC |
120 ms |
3944 KiB |
| 04_rand_2_01.txt |
AC |
68 ms |
3800 KiB |
| 04_rand_2_02.txt |
AC |
69 ms |
3980 KiB |
| 04_rand_2_03.txt |
AC |
69 ms |
3800 KiB |
| 04_rand_2_04.txt |
AC |
69 ms |
3976 KiB |
| 04_rand_2_05.txt |
AC |
69 ms |
3872 KiB |
| 04_rand_2_06.txt |
AC |
69 ms |
3952 KiB |
| 04_rand_2_07.txt |
AC |
69 ms |
3760 KiB |
| 04_rand_2_08.txt |
AC |
69 ms |
3748 KiB |
| 04_rand_2_09.txt |
AC |
69 ms |
3896 KiB |
| 04_rand_2_10.txt |
AC |
69 ms |
3856 KiB |
| 05_rand_3_01.txt |
AC |
185 ms |
3900 KiB |
| 05_rand_3_02.txt |
AC |
184 ms |
3892 KiB |
| 05_rand_3_03.txt |
AC |
185 ms |
3904 KiB |
| 05_rand_3_04.txt |
AC |
185 ms |
3896 KiB |
| 05_rand_3_05.txt |
AC |
184 ms |
3744 KiB |
| 05_rand_3_06.txt |
AC |
184 ms |
3868 KiB |
| 05_rand_3_07.txt |
AC |
184 ms |
3864 KiB |
| 05_rand_3_08.txt |
AC |
184 ms |
3740 KiB |
| 05_rand_3_09.txt |
AC |
185 ms |
3800 KiB |
| 05_rand_3_10.txt |
AC |
184 ms |
3796 KiB |