QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#767685 | #9627. 算术 | rool123 | AC ✓ | 967ms | 4068kb | C++23 | 1.5kb | 2024-11-20 21:44:38 | 2024-11-20 21:44:41 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define vi vector<int>
#define vll vector<long long>
#define double long double
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<'*'<<x<<'\n';
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define rep(x, y) for(int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const int mod=998244353;
ll gcd(ll a,ll b)
{
return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b)
{
return a*b/gcd(a,b);
}
ll qmi(ll a,ll b)
{
ll ans=1;
while(b)
{
if(b&1)ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans;
}
void solve()
{
vi arr(10), res;
rep(1, 9)cin >> arr[i];
double Max = 0;
rep(0, arr[1])
{
double lans = 0;
vi now;
priority_queue<int, vector<int>, greater<int>>q;
for(int j = 1; j <= 9; j++)
{
int n = arr[j];
if(j == 1)n = i;
for(int k = 1; k <= n; k++)q.push(j);
}
int x = arr[1] - i;
while(q.size() && x --)
{
int t = q.top();
q.pop();
q.push(t+1);
}
while(q.size())
{
now.pb(q.top());
lans += log(q.top());
q.pop();
}
if(lans > Max)
{
Max = lans;
res = now;
}
}
int answer = 1;
for(auto x : res)answer = answer * x % mod;
cout << answer << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int _;
_=1;
cin>>_;
while(_--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 5ms
memory: 4068kb
input:
7 5 3 0 0 0 0 0 0 0 4 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 2 99 88 77 66 55 44 33 22 11 100 90 80 70 60 50 40 30 20
output:
54 108 1 10 90 90553232 143532368
result:
ok 7 lines
Test #2:
score: 0
Accepted
time: 967ms
memory: 3872kb
input:
1000 22 80 50 23 35 71 81 70 96 40 33 36 2 51 52 96 5 32 56 35 85 13 58 80 26 14 31 60 21 8 19 79 5 94 44 33 85 55 10 59 76 98 28 22 69 14 72 40 14 100 68 5 18 69 95 42 51 0 32 97 37 34 85 54 33 18 40 34 10 72 72 68 81 47 80 23 23 68 40 3 71 58 7 36 79 89 83 5 68 16 30 3 82 79 35 28 30 55 88 17 86 2...
output:
376701872 321820208 765709043 819408880 639261805 521201354 7172464 780360907 240853384 151457742 298466126 416189734 124742738 161566750 493291429 481038778 409158325 951979430 783007793 438976523 440485591 163247072 78098984 275527515 308024444 168349368 423889166 168234582 827159852 914298923 465...
result:
ok 1000 lines
Test #3:
score: 0
Accepted
time: 78ms
memory: 3856kb
input:
1000 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0...
output:
1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 10 4 6 8 10 12 14 16 18 9 12 15 18 21 24 27 16 20 24 28 32 36 25 30 35 40 45 36 42 48 54 49 56 63 64 72 81 53234520 78732 944784 17744840 53234520 688747536 141958720 19131876 4374 9726857 668738521 35489680 11664 79851780 8748 104630853 551437603 234594227 96996101...
result:
ok 1000 lines