QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#591104 | #8635. 圆 | wanggk | 40 | 0ms | 3840kb | C++14 | 1.3kb | 2024-09-26 14:10:51 | 2024-09-26 14:10:51 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,il,ir) for(register int i=(il);i<=(ir);++i)
#define Forr(i,ir,il) for(register int i=(ir);i>=(il);--i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T>
inline void read(T& x){
bool f=0;x=0;char ch=getchar();
while(ch<'0'||ch>'9'){ if(ch=='-') f=1; ch=getchar(); }
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
if(f) x=-x;
}
template<typename T,typename... Args>
void read(T& first,Args&... args){ read(first),read(args...); }
const ll mod=998244353;
namespace stO_Orz{
int n;
ll ans=0,sum=0;
bool vis[15];
int black[15];
ll qp(ll x,ll base){
ll res=1ll;
while(base){
if(base&1) res=res*x%mod;
x=x*x%mod,base>>=1;
}return res;
}
ll dfs()
{
bool flag=1;
for(int i=0;i<n&&flag;++i) if(!black[i]) flag=0;
if(flag) return 0;
ll res=0,sum=0;
for(int i=0;i<n;++i) if(!vis[i])
{
vis[i]=1;
for(int j=i-1;j<=i+1;++j) ++black[(j+n)%n];
res+=(1+dfs()),sum++;
for(int j=i-1;j<=i+1;++j) --black[(j+n)%n];
vis[i]=0;
}
return res*qp(sum,mod-2ll)%mod;
}
signed my_main()
{
read(n);
vis[0]=1,black[0]=black[n-1]=black[1]=1;
printf("%lld\n",(dfs()+1)%mod);
return 0;
}
}
signed main(){ return stO_Orz::my_main(); }
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 0ms
memory: 3684kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 10
Accepted
time: 0ms
memory: 3772kb
input:
4
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 10
Accepted
time: 0ms
memory: 3748kb
input:
6
output:
299473309
result:
ok 1 number(s): "299473309"
Test #4:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
10
output:
487238321
result:
ok 1 number(s): "487238321"
Test #5:
score: 0
Runtime Error
input:
100
output:
result:
Test #6:
score: 0
Runtime Error
input:
200
output:
result:
Test #7:
score: 0
Runtime Error
input:
500
output:
result:
Test #8:
score: 0
Runtime Error
input:
4798
output:
result:
Test #9:
score: 0
Runtime Error
input:
4999
output:
result:
Test #10:
score: 0
Runtime Error
input:
5000