QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#668250#7716. Average Valueucup-team173#WA 1ms3752kbC++20896b2024-10-23 13:06:462024-10-23 13:06:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-23 13:06:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3752kb
  • [2024-10-23 13:06:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using i128 = __int128_t;
constexpr ll P = 1e18 + 9;

ll qpow(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b & 1) res = (i128)res * a % P;
        a = (i128)a * a % P, b >>= 1;
    }
    return res;
}
void solve() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    ll prod = 1;
    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for(auto ch : s) {
            a[i] = ((i128)10 * a[i] + ch - '0') % P;
        }
        prod = (i128)prod * a[i] % P;
    }
    for(int i = 1; i <= n; i++) {
        if(qpow(a[i], n) == prod) {
            cout << i << '\n';
            return;
        }
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3564kb

input:

5
2 4 8 16 32

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3424kb

input:

2
123456789012345678901234567890 123456789012345678901234567890

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

10
64 8 64 4096 32768 8 64 8 8 8

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

10
64 8 512 64 8 64 64 512 8 512

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

10
1000 40 40 200 40 40 8 8 40 8

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

10
49 1512 2286144 1764 49 12348 294 1512 12348 294

output:

4

result:

ok 1 number(s): "4"

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 3504kb

input:

10
125 102400 12800 25 1000 1600 12800 1000000 8000 1600000

output:

2

result:

wrong answer 1st numbers differ - expected: '9', found: '2'