QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#542203 | #8932. Bingo | ucup-team3584# | WA | 1ms | 3624kb | C++17 | 5.1kb | 2024-08-31 23:26:06 | 2024-08-31 23:26:07 |
Judging History
answer
#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> using vvvc = vector<vector<vector<T>>>;
template<class T> using pq = priority_queue<T,vector<T>,greater<T>>;
template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
int dx4[] = {1,0,-1,0};
int dy4[] = {0,1,0,-1};
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf)
#define REP1(i, n) for(ll i = 0; i < (n); ++i)
#define REP2(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf)
#define per1(i, n) for(ll i = (n)-1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (a)-1; i >= b; --i)
#define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__)
#define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii))
#define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define drop(s) cout << #s << endl, exit(0)
#define si(c) (int)(c).size()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
#define rng(v, l, r) v.begin() + (l), v.begin() + (r)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define SORT(v) sort(all(v))
#define REV(v) reverse(all(v))
#define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end())
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--) {
string n;
int m;
cin >> n >> m;
int ans = 0;
rep(i,si(n)) {
ans = (10ll*ans+n[i]-'0')%m;
}
vc<string>ss;
auto stradd = [&](string a,int b) -> string {
string fans;
int id = 0,f = 0;
while(b) {
int now = b%10+f;
if(id < si(a)) {
now += a[si(a)-1-id]-'0';
}
fans += (char)('0'+now%10);
b /= 10;
f = now/10;
id++;
}
if(id < si(a)) {
rep(i,id,si(a)) {
fans += a[si(a)-i-1];
}
}
REV(fans);
return fans;
};
ss.pb(stradd(n,m-ans));
n = stradd(n,1);
string r = to_string(m);
bool f = false;
rep(i,si(n)) {
if(i+si(r) <= si(n)) {
if(n.substr(i,si(r)) == r) {
f = true;
break;
}
}
}
if(f) {
cout << n << "\n";
continue;
}
rep(i,si(n)) {
if(i+si(r) <= si(n) && si(n)-i+si(r) <= 30) {
if(n.substr(i,si(r)) < r) {
ss.pb(n.substr(0,i)+r+string(si(n)-i-si(r),'0'));
}
else if(i) {
ss.pb(stradd(n.substr(0,i),1)+r+string(si(n)-i-si(r),'0'));
}
}
}
string zans = ss[0];
rep(i,1,si(ss)) {
if(si(zans) > si(ss[i])) {
zans = ss[i];
}
else if(si(zans) == si(ss[i]) && zans > ss[i]) {
zans = ss[i];
}
}
cout << zans << "\n";
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3624kb
input:
6 7 3 12 3 9 10 249 51 1369 37 2 1
output:
9 13 0 245 1306 3
result:
wrong answer 3rd lines differ - expected: '10', found: '0'