QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#823377 | #9864. Coin | LeoG | WA | 17ms | 3656kb | C++23 | 3.3kb | 2024-12-20 22:46:52 | 2024-12-20 22:46:52 |
Judging History
answer
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#define ll long long
#define all(v) v.begin(),v.end()
#define ld long double
#define pll std::pair<ll,ll>
#define pi std::pair<int,int>
#define vi std::vector<int>
#define vll std::vector<ll>
#define len(x) (int)x.size()
#define vec(T) std::vector<T>
#define PI (ld)3.14159265358979323846
// overload << for pair
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::pair<T, T>& pair) {
std::cout << "(" << pair.first << ", " << pair.second << ")";
return os;
}
// overload << for vec
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
os << "[";
for (size_t i = 0; i < vec.size(); ++i) {
os << vec[i] << (i == vec.size() - 1 ? "\0" : ", ");
}
os << "]";
return os;
}
// overload << for map and unordered_map Output
template<typename Map>
void printMap(const Map& m) {
std::cout << '{';
for (auto it = m.begin(); it != m.end(); it++) {
std::cout << it -> first << ": " << it -> second << (std::next(it) == m.end() ? "\0" : ", ");
}
std::cout << "}";
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m) {
printMap(m);
return os;
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::unordered_map<K, V>& m) {
printMap(m);
return os;
}
// overload << for set and unordered_set Output
template<typename Set>
void printSet(const Set& s) {
std::cout << '{';
for (auto it = s.begin(); it != s.end(); it++) {
std::cout << *it << (std::next(it) == s.end() ? "\0" : ", ");
}
std::cout << "}";
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& s) {
printSet(s);
return os;
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::unordered_set<T>& s) {
printSet(s);
return os;
}
// General print function
template <typename T>
void print(const T& val) {
std::cout << val << std::endl;
}
// Variadic template print function
template<typename T, typename... Args>
void print(const T& t, const Args&... args) {
std::cout << t << ' ';
print(args...);
if (sizeof...(args) == 1) std::cout << '\n';
}
void solve(){
ll n, m;
std::cin >> n >> m;
ll x = m - 1;
auto f = [&](ll t) {
ll l = t, r = n;
while (l < r) {
ll mid = (l + r) / 2;
if (mid - mid / m - 1 >= x) {
r = mid;
}
else {
l = mid + 1;
}
}
return l;
};
while (true) {
ll tmp = f(x);
if (tmp >= n) break;
x = tmp;
}
print(x + 1);
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
std::cin >> t;
while (t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 17ms
memory: 3504kb
input:
4 6 2 8 3 10000 2 1919810 114514
output:
4 8 8192 1919805
result:
ok 4 number(s): "4 8 8192 1919805"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3656kb
input:
100 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 4 11 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 5 11 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 6 10 6 11 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 7 10 7 11 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 8 10 8 11 9 ...
output:
2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10 11 4 3 4 5 6 7 8 9 10 11 4 5 4 5 6 7 8 9 10 11 4 5 6 5 6 7 8 9 10 11 4 5 6 7 6 7 8 9 10 11 8 8 8 7 8 7 8 9 10 11 8 8 8 9 8 9 8 9 10 11 8 8 8 9 10 9 10 9 10 11 8 8 11 9 10 11 10 11 10 11
result:
wrong answer 2nd numbers differ - expected: '2', found: '3'