QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#21559 | #2851. 生生不息 | Mr_Eight# | AC ✓ | 4ms | 3660kb | C++14 | 2.8kb | 2022-03-07 15:02:48 | 2022-05-08 03:38:09 |
Judging History
answer
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define itn int
#define nit int
#define ll __int128
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
//#pra gma G CC opti mize(3)
using namespace std;
using std::bitset;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
template<class T>
inline void read(T &x) {
x=0;
bool fu=0;
char ch=0;
while(ch>'9'||ch<'0') {
ch=getchar();
if(ch=='-')fu=1;
}
while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
if(fu)x=-x;
}
inline int read() {
int x=0;
bool fu=0;
char ch=0;
while(ch>'9'||ch<'0') {
ch=getchar();
if(ch=='-')fu=1;
}
while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
return fu?-x:x;
}
template<class T,class... Args>
inline void read(T& t,Args&... args) {
read(t);
read(args...);
}
char _n_u_m_[40];
template<class T>
inline void write(T x ) {
if(x==0){
putchar('0');
return;
}
T tmp = x > 0 ? x : -x ;
if( x < 0 ) putchar('-') ;
register int cnt = 0 ;
while( tmp > 0 ) {
_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
tmp /= 10 ;
}
while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
}
template<class T>
inline void write(T x ,char ch) {
write(x);
putchar(ch);
}
}
using namespace fastIO;
ll mod;
inline ll pw(ll x,ll p){
long long res=1;
for(;p;p>>=1,x=x*x%mod)
if(p&1)res=res*x%mod;
return res;
}
inline ll exgcd(ll a,ll b,ll &x,ll &y) {
if(b==0) {
x=1;
y=0;
return a;
}
ll r=exgcd(b,a%b,y,x);
y-=a/b*x;
return r;
}
inline ll inv(ll x){
ll t1=0,t2=0;
exgcd(mod,x,t1,t2);
return (t2%mod+mod)%mod;
}
inline ll solve(ll c1,ll c2,ll e1,ll e2){
if(!e2){
return c1;
}
ll v=e1/e2;//cerr<<e1<<" "<<e2<<" "<<vendl;
ll temp=pw(c2,v);
c1=(__int128(1))*c1*inv(temp)%mod;
e1%=e2;
return solve(c2,c1,e2,e1);
}
int ans[6][6];
int main(){
ans[2][2]=5,ans[3][3]=150,ans[3][2]=18;
ans[4][2]=73,ans[4][3]=1533,ans[4][4]=31828;
ans[5][2]=267,ans[5][3]=11398,ans[5][4]=469972,ans[5][5]=12785753;
F(asdf,1,read()){
int n=read(),m=read();
if(n<m)swap(n,m);
write(ans[n][m],'\n');
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 3660kb
input:
25 2 4 2 3 2 1 1 5 4 2 5 4 5 3 2 5 1 4 4 4 5 2 5 1 4 5 3 3 3 2 4 3 5 5 3 1 4 1 3 5 3 4 1 3 1 2 2 2 1 1
output:
73 18 0 0 73 469972 11398 267 0 31828 267 0 469972 150 18 1533 12785753 0 0 11398 1533 0 0 5 0
result:
ok 25 lines