QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#570545 | #9308. World Cup | Niiu | AC ✓ | 3ms | 3620kb | C++20 | 8.0kb | 2024-09-17 16:26:16 | 2024-09-17 16:26:19 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(nullptr);
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
using namespace std;
using i32 = int;
using i64 = long long;
using i128 = __int128;
template <typename T>
T read()
{
T sum = 0, fl = 1;
int ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-')
fl = -1;
for (; isdigit(ch); ch = getchar())
sum = sum * 10 + ch - '0';
return sum * fl;
}
template <typename T>
void write(T x)
{
if (x < 0)
{
x = -x;
putchar('-');
}
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
template <typename T>
constexpr T power(T a, i64 b)
{
T res = 1;
for (; b; b /= 2, a *= a) {
if (b % 2) {
res *= a;
}
}
return res;
}
constexpr i64 mul(i64 a, i64 b, i64 p)
{
i64 res = a * b - i64(1.L * a * b / p) * p;
res %= p;
if (res < 0) {
res += p;
}
return res;
}
template <i64 P>
struct MLong {
i64 x;
constexpr MLong()
: x {}
{
}
constexpr MLong(i64 x)
: x { norm(x % getMod()) }
{
}
static i64 Mod;
constexpr static i64 getMod()
{
if (P > 0) {
return P;
} else {
return Mod;
}
}
constexpr static void setMod(i64 Mod_)
{
Mod = Mod_;
}
constexpr i64 norm(i64 x) const
{
if (x < 0) {
x += getMod();
}
if (x >= getMod()) {
x -= getMod();
}
return x;
}
constexpr i64 val() const
{
return x;
}
explicit constexpr operator i64() const
{
return x;
}
constexpr MLong operator-() const
{
MLong res;
res.x = norm(getMod() - x);
return res;
}
constexpr MLong inv() const
{
assert(x != 0);
return power(*this, getMod() - 2);
}
constexpr MLong& operator*=(MLong rhs) &
{
x = mul(x, rhs.x, getMod());
return *this;
}
constexpr MLong& operator+=(MLong rhs) &
{
x = norm(x + rhs.x);
return *this;
}
constexpr MLong& operator-=(MLong rhs) &
{
x = norm(x - rhs.x);
return *this;
}
constexpr MLong& operator/=(MLong rhs) &
{
return *this *= rhs.inv();
}
friend constexpr MLong operator*(MLong lhs, MLong rhs)
{
MLong res = lhs;
res *= rhs;
return res;
}
friend constexpr MLong operator+(MLong lhs, MLong rhs)
{
MLong res = lhs;
res += rhs;
return res;
}
friend constexpr MLong operator-(MLong lhs, MLong rhs)
{
MLong res = lhs;
res -= rhs;
return res;
}
friend constexpr MLong operator/(MLong lhs, MLong rhs)
{
MLong res = lhs;
res /= rhs;
return res;
}
friend constexpr std::istream& operator>>(std::istream& is, MLong& a)
{
i64 v;
is >> v;
a = MLong(v);
return is;
}
friend constexpr std::ostream& operator<<(std::ostream& os, const MLong& a)
{
return os << a.val();
}
friend constexpr bool operator==(MLong lhs, MLong rhs)
{
return lhs.val() == rhs.val();
}
friend constexpr bool operator!=(MLong lhs, MLong rhs)
{
return lhs.val() != rhs.val();
}
};
template <>
i64 MLong<0LL>::Mod = 1;
template <int P>
struct MInt {
int x;
constexpr MInt()
: x {}
{
}
constexpr MInt(i64 x)
: x { norm(x % getMod()) }
{
}
static int Mod;
constexpr static int getMod()
{
if (P > 0) {
return P;
} else {
return Mod;
}
}
constexpr static void setMod(int Mod_)
{
Mod = Mod_;
}
constexpr int norm(int x) const
{
if (x < 0) {
x += getMod();
}
if (x >= getMod()) {
x -= getMod();
}
return x;
}
constexpr int val() const
{
return x;
}
explicit constexpr operator int() const
{
return x;
}
constexpr MInt operator-() const
{
MInt res;
res.x = norm(getMod() - x);
return res;
}
constexpr MInt inv() const
{
assert(x != 0);
return power(*this, getMod() - 2);
}
constexpr MInt& operator*=(MInt rhs) &
{
x = 1LL * x * rhs.x % getMod();
return *this;
}
constexpr MInt& operator+=(MInt rhs) &
{
x = norm(x + rhs.x);
return *this;
}
constexpr MInt& operator-=(MInt rhs) &
{
x = norm(x - rhs.x);
return *this;
}
constexpr MInt& operator/=(MInt rhs) &
{
return *this *= rhs.inv();
}
friend constexpr MInt operator*(MInt lhs, MInt rhs)
{
MInt res = lhs;
res *= rhs;
return res;
}
friend constexpr MInt operator+(MInt lhs, MInt rhs)
{
MInt res = lhs;
res += rhs;
return res;
}
friend constexpr MInt operator-(MInt lhs, MInt rhs)
{
MInt res = lhs;
res -= rhs;
return res;
}
friend constexpr MInt operator/(MInt lhs, MInt rhs)
{
MInt res = lhs;
res /= rhs;
return res;
}
friend constexpr std::istream& operator>>(std::istream& is, MInt& a)
{
i64 v;
is >> v;
a = MInt(v);
return is;
}
friend constexpr std::ostream& operator<<(std::ostream& os, const MInt& a)
{
return os << a.val();
}
friend constexpr bool operator==(MInt lhs, MInt rhs)
{
return lhs.val() == rhs.val();
}
friend constexpr bool operator!=(MInt lhs, MInt rhs)
{
return lhs.val() != rhs.val();
}
};
template <>
int MInt<0>::Mod = 1;
template <int V, int P>
constexpr MInt<P> CInv = MInt<P>(V).inv();
constexpr int P = 1e9 + 7;//改取模数
using Z = MInt<P>;
struct Comb {
int n;
std::vector<Z> _fac;
std::vector<Z> _invfac;
std::vector<Z> _inv;
Comb()
: n { 0 }
, _fac { 1 }
, _invfac { 1 }
, _inv { 0 }
{
}
Comb(int n)
: Comb()
{
init(n);
}
void init(int m)
{
if (m <= n)
return;
_fac.resize(m + 1);
_invfac.resize(m + 1);
_inv.resize(m + 1);
for (int i = n + 1; i <= m; i++) {
_fac[i] = _fac[i - 1] * i;
}
_invfac[m] = _fac[m].inv();
for (int i = m; i > n; i--) {
_invfac[i - 1] = _invfac[i] * i;
_inv[i] = _invfac[i] * _fac[i - 1];
}
n = m;
}
Z fac(int m)
{
if (m > n)
init(2 * m);
return _fac[m];
}
Z invfac(int m)
{
if (m > n)
init(2 * m);
return _invfac[m];
}
Z inv(int m)
{
if (m > n)
init(2 * m);
return _inv[m];
}
Z binom(int n, int m)
{
if (n < m || m < 0)
return 0;
return fac(n) * invfac(m) * invfac(n - m);
}
} comb;
void solve()
{
vector<pair<int,int>> a(33);
for(int i=1;i<=32;i++)
{
cin>>a[i].first;
a[i].second=i;
}
sort(a.begin()+1,a.end());
int cnt;
for(int i=1;i<=32;i++)
{
if(a[i].second==1)
{
cnt=i-1;
break;
}
}
if(cnt<2)cout<<32<<'\n';
if(cnt>=2&&cnt<6)cout<<16<<'\n';
if(cnt>=6&&cnt<13)cout<<8<<'\n';
if(cnt>=13&&cnt<27)cout<<4<<'\n';
if(cnt>=27&&cnt<=30)cout<<2<<'\n';
if(cnt==31)cout<<1<<'\n';
}
signed main()
{
IOS
int T = 1;
cin>>T;
while (T--)
{
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
input:
1 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 4 1 2 3 5 6 7 8 9 10 11 12 13 14 15 ...
output:
32 32 16 16 16 16 8 8 8 8 8 8 8 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 1
result:
ok 32 numbers
Test #3:
score: 0
Accepted
time: 3ms
memory: 3620kb
input:
1000 158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784 450968417 430302156 982631932 161735902 880895728 923078537 707723857 189330739 910286918 802329211 404539679 303238506 317063340 492686568 773361868 125660...
output:
16 4 1 4 1 4 4 2 4 2 4 32 4 2 4 4 8 4 32 1 4 4 2 4 2 16 2 8 4 8 8 1 2 4 8 4 16 4 4 2 4 4 2 16 8 4 2 16 4 8 8 4 4 4 4 16 16 2 1 4 4 8 1 4 4 2 4 8 16 4 4 8 4 32 32 8 8 8 1 4 4 4 4 4 32 8 4 4 8 32 4 4 16 2 8 32 16 8 8 4 1 4 4 16 32 4 4 4 4 4 8 4 4 8 4 4 4 8 16 4 4 8 2 4 4 16 2 8 16 4 4 16 2 32 8 16 4 3...
result:
ok 1000 numbers
Extra Test:
score: 0
Extra Test Passed