QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#174091 | #6637. Perfect Strings | PERAPRO# | WA | 96ms | 3484kb | C++14 | 979b | 2023-09-10 04:10:27 | 2023-09-10 04:10:27 |
Judging History
answer
#include <bits/stdc++.h>
#include <ios>
#define ll long long int
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<ll>
#define lli long long
#define vii vector<ii>
#define pb push_back
#define fast_io \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using namespace std;
const int N = 2e5;
const ll MOD = 1e9 + 7;
ll fpow(ll base, ll e) {
ll ans = 1;
while (e) {
if (e & 1) {
ans = (ans * base) % MOD;
}
base = (base * base) % MOD;
e >>= 1;
}
return ans;
}
int main() {
int tc;
cin >> tc;
while (tc--) {
ll n, c;
cin >> n >> c;
ll res = (pow(2, n - 1) * (((fpow(c, n) - c + MOD) % MOD)));
res += c;
res %= MOD;
cout << res << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
input:
2 3 1 2 2
output:
1 6
result:
ok 2 number(s): "1 6"
Test #2:
score: -100
Wrong Answer
time: 96ms
memory: 3480kb
input:
100000 1 1 4 1 5 5 3 5 1 2 5 3 1 1 3 3 5 2 2 1 4 1 5 5 2 3 4 1 3 3 2 5 3 2 4 3 4 4 3 5 3 1 5 2 2 2 4 2 5 4 1 2 3 1 4 5 2 5 5 3 1 5 5 2 3 2 5 2 4 1 1 3 3 2 4 5 2 1 4 1 2 2 1 1 3 5 4 5 2 3 3 5 2 5 2 4 5 4 2 3 1 1 2 1 4 4 1 5 5 4 1 3 5 4 4 5 1 3 1 1 3 3 2 4 2 4 2 1 5 5 1 3 2 3 4 1 4 3 2 4 2 4 4 2 1 1 1...
output:
1 1 49925 485 2 3843 1 99 482 1 1 49925 15 1 99 45 26 627 2020 485 1 482 6 114 16324 2 1 4965 45 3843 5 482 26 482 1 3 26 4965 1 1 6 1 485 4965 15 485 45 28 16324 15 1 1 2020 5 16324 3 16324 4965 3 1 99 28 28 1 49925 3 15 1 627 28 28 114 1 1 49925 15 2020 3 1 2 15 99 2020 16324 49925 6 482 2020 482 ...
result:
wrong answer 3rd numbers differ - expected: '71445', found: '49925'