Task: | Finding inverse |
Sender: | paulschulte |
Submission time: | 2024-11-17 13:44:19 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.02 s | details |
#10 | WRONG ANSWER | 0.03 s | details |
#11 | WRONG ANSWER | 0.01 s | details |
#12 | TIME LIMIT EXCEEDED | -- | details |
#13 | TIME LIMIT EXCEEDED | -- | details |
#14 | TIME LIMIT EXCEEDED | -- | details |
Code
// ~/.vim/cpp_template.cpp #include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <string> #include <limits> #define REP(i,a,b) for (int i = a; i < b; i++) // Type Aliases for 1D and 2D vectors with initialization #define vi(n, val) vector<int>(n, val) // 1D vector of ints with size n, initialized to val #define vll(n, val) vector<long long>(n, val) // 1D vector of long longs with size n, initialized to val #define ll long long #define vvi(n, m, val) vector<vector<int>>(n, vector<int>(m, val)) // 2D vector of ints (n x m), initialized to val #define vvll(n, m, val) vector<vector<long long>>(n, vector<long long>(m, val)) // 2D vector of long longs (n x m), initialized to val #define LL_INF std::numeric_limits<long long int>::max() #define INF std::numeric_limits<int>::max() using namespace std; template <typename T> void pV(const std::vector<T>& vec, const std::string& label = "Vector") { std::cout << label << ": [ "; for (const auto& elem : vec) { std::cout << elem << " "; } std::cout << "]" << std::endl; } void dfs(int s, vector<bool> *visited, vector<int> (*adj)[]) { if ((*visited)[s]) return; (*visited)[s] = true; // process node s for (auto u: (*adj)[s]) { dfs(u, visited, adj); } } /* // DEPTH-FRIRST-SEARCH vector<int> adj[N]; vector<bool> visited(N, false); int u, v; for(int i = 0; i < M;i++){ cin >> u >> v; u--; v--; adj[u].push_back(v); adj[v].push_back(u); } */ vector<long long> dijkstra(int N, int x, vector<vector<pair<int,int>>> *adj){ vector<bool> processed(N, false); vector<long long> distance(N, LL_INF); priority_queue<pair<long long,int>> q; //for (int i = 1; i <= n; i++) distance[i] = INF; distance[x] = 0; q.push({0,x}); while (!q.empty()) { int a = q.top().second; q.pop(); if (processed[a]) continue; processed[a] = true; for (auto u : (*adj)[a]) { int b = u.first, w = u.second; if (distance[a]+w < distance[b]) { distance[b] = distance[a]+w; q.push({-distance[b],b}); } } } return distance; } /* DIJKSTRA //vector<vector<pair<int,int>>> adj(N, vector<pair<int, int>>(N)); */ const int M = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); // Your code starts here int n; cin >> n; REP(i, 0, n){ long long a, b; cin >> a >> b; if (a == 0 && b == 0){ cout << 1 << "\n"; continue; } long long res = 1; a = a % M; while(b > 0){ if (b % 2 == 1) { res = (res * a) % M; } a = (a * a) % M; b /= 2; } cout << res << "\n"; } cout << endl; return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
6 7 |
correct output |
---|
6 |
user output |
---|
282475249 1 1 1 1 ... |
Test 2
Verdict: WRONG ANSWER
input |
---|
0 7 |
correct output |
---|
-1 |
user output |
---|
(empty) |
Test 3
Verdict: WRONG ANSWER
input |
---|
5 78 |
correct output |
---|
47 |
user output |
---|
885769020 1 1 1 1 ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
89 99 |
correct output |
---|
89 |
user output |
---|
813000932 1 1 1 1 ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
0 61 |
correct output |
---|
-1 |
user output |
---|
(empty) |
Test 6
Verdict: WRONG ANSWER
input |
---|
897 947 |
correct output |
---|
625 |
user output |
---|
394287905 1 1 1 1 ... |
Test 7
Verdict: WRONG ANSWER
input |
---|
419 538 |
correct output |
---|
217 |
user output |
---|
19492643 1 1 1 1 ... |
Test 8
Verdict: WRONG ANSWER
input |
---|
32 938 |
correct output |
---|
-1 |
user output |
---|
700768941 1 1 1 1 ... |
Test 9
Verdict: WRONG ANSWER
input |
---|
184120 505187 |
correct output |
---|
438779 |
user output |
---|
480991402 1 1 1 1 ... |
Test 10
Verdict: WRONG ANSWER
input |
---|
264601 885661 |
correct output |
---|
360221 |
user output |
---|
671697713 1 1 1 1 ... |
Test 11
Verdict: WRONG ANSWER
input |
---|
40310 590135 |
correct output |
---|
-1 |
user output |
---|
118327527 1 1 1 1 ... |
Test 12
Verdict: TIME LIMIT EXCEEDED
input |
---|
202254499 577081420 |
correct output |
---|
128866679 |
user output |
---|
(empty) |
Test 13
Verdict: TIME LIMIT EXCEEDED
input |
---|
539836073 888851205 |
correct output |
---|
797044652 |
user output |
---|
(empty) |
Test 14
Verdict: TIME LIMIT EXCEEDED
input |
---|
697847215 756971670 |
correct output |
---|
-1 |
user output |
---|
(empty) |