QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524161 | #5661. Multi-Ladders | ucup-team3699# | Compile Error | / | / | C++20 | 1.5kb | 2024-08-19 11:22:46 | 2024-08-19 11:22:46 |
Judging History
answer
using namespace std;
#define int long long
const int mod = 1e9 + 7;
int mat[2][2];
int a[2];
int fpow(int x, int p){
int ret = 1;
while(p){
if(p & 1)
ret = ret * x % mod;
x = x * x % mod;
p >>= 1;
}
return ret;
}
void mul(){
int ret[2][2] = {0, 0, 0, 0};
for (int i = 0; i < 2; i++){
for (int j = 0; j < 2; j++){
for (int k = 0; k < 2; k++)
ret[i][j] += mat[i][k] * mat[k][j] % mod, ret[i][j] %= mod;
}
}
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
mat[i][j] = ret[i][j];
}
void mul2(){
int ret[2] = {0, 0};
ret[0] = mat[0][0] * a[0] + mat[0][1] * a[1], ret[0] %= mod;
ret[1] = mat[1][0] * a[0] + mat[1][1] * a[1], ret[1] %= mod;
a[0] = ret[0], a[1] = ret[1];
}
void solve(){
int n, k, c;
cin >> n >> k >> c;
mat[0][0] = c - 2, mat[0][1] = c - 1, mat[1][0] = 1, mat[1][1] = 0;
a[0] = (c - 1) * c % mod, a[1] = c;
int tmp = k - 2;
while(tmp){
if(tmp & 1){
mul2();
}
mul();
tmp >>= 1;
}
int ans = a[0];
cout << ans << "\n";
int b = c - 1 + (c - 2) * (c - 2);
b %= mod;
ans = ans * fpow(b, k * (n - 1)) % mod;
cout << ans << "\n";
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int t = 1;
cin >> t;
while(t--)
solve();
return 0;
}
Details
answer.code: In function ‘void solve()’: answer.code:37:5: error: ‘cin’ was not declared in this scope 37 | cin >> n >> k >> c; | ^~~ answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? +++ |+#include <iostream> 1 | answer.code:49:5: error: ‘cout’ was not declared in this scope 49 | cout << ans << "\n"; | ^~~~ answer.code:49:5: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’? answer.code: In function ‘int main()’: answer.code:56:5: error: ‘ios_base’ has not been declared 56 | ios_base::sync_with_stdio(0), cin.tie(0); | ^~~~~~~~ answer.code:56:35: error: ‘cin’ was not declared in this scope 56 | ios_base::sync_with_stdio(0), cin.tie(0); | ^~~ answer.code:56:35: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?