提出 #35546577
ソースコード 拡げる
// Problem: B - Make Divisible
// Contest: AtCoder - AtCoder Regular Contest 150
// URL: https://atcoder.jp/contests/arc150/tasks/arc150_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
#define F(i, j, k) for (int i = j; i <= k; i++)
#define R(i, j, k) for (int i = j; i >= k; i--)
#define Fi F(i, 1, n)
#define Fj F(j, 1, n)
#define Fk F(k, 1, n)
#define Fto(x) F(i, 1, x)
#define Ri R(i, n, 1)
#define Rj R(j, n, 1)
#define Rk R(k, n, 1)
#define Rto(x) R(i, x, 1)
#define ll long long
#define ull unsigned ll
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define ld long double
#define vld vector<ld>
#define vvld vector<vld>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pq priority_queue
#define inf INT_MAX
#define linf LLONG_MAX
#define dinf 1e308
#define DEBUG1(x) clog << __LINE__ << #x << ": " << x << endl
#define DEBUG2(x, y) \
clog << __LINE__ << #x << ": " << x << " " << #y << ": " << y << endl
#define EXIT \
getchar(); \
getchar(); \
exit(0);
#define Pr9 998244353
#define Pr7 1000000007
inline ll read() {
ll x = 0, d = 1, t = 1;
char c = getchar();
while (!isdigit(c) && (c != '-')) c = getchar();
if (c == '-') d = -1, c = getchar();
while (isdigit(c)) {
x = x * 10 + c - 48;
c = getchar();
}
return x * d;
}
inline void write(ll x) {
if (x < 0) putchar('-'), x = -x;
if (x > 9) write(x / 10);
putchar(x % 10 + 48);
}
inline void writeln(ll x) {
write(x);
putchar('\n');
}
inline void reads(ll *a, int n) {
Fi { a[i] = read(); }
}
inline void reads(int *a, int n) {
Fi { a[i] = read(); }
}
inline void writes(ll *a, int n) {
Fi {
write(a[i]);
putchar(' ');
}
putchar('\n');
}
inline void PMG(ll &x, ll y, ll p) {
x += y;
if (x >= p) x -= p;
}
inline void MMG(ll &x, ll y, ll p) { PMG(x, p - y, p); }
inline ll PM(ll x, ll y, ll p) {
x += y;
if (x >= p) x -= p;
return x;
}
inline ll MM(ll x, ll y, ll p) { return PM(x, p - y, p); }
inline ll FM(ll x, ll p) {
if (x >= (p << 3)) return x % p;
if (x >= (p << 2)) x -= (p << 2);
if (x >= (p << 1)) x -= (p << 1);
if (x >= p) x -= p;
return x;
}
inline ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x % y); }
inline ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
inline ll FMP(ll x, ll y, ll p) {
ll ans = 1;
while (y) {
if (y & 1) ans = ans * x % p;
x = x * x % p;
y >>= 1;
}
return ans;
}
struct Mi7 {
ll inner;
Mi7() : inner(1) {}
Mi7(ll x) : inner(FM(x, Pr7)) {}
Mi7 operator+(Mi7 x) { return PM(inner, x.inner, Pr7); }
Mi7 operator-(Mi7 x) { return MM(inner, x.inner, Pr7); }
Mi7 operator*(Mi7 x) { return FM(inner * x.inner, Pr7); }
Mi7 operator~() { return FMP(inner, Pr7 - 2, Pr7); }
Mi7 operator/(Mi7 x) { return FM(inner * (~x).inner, Pr7); }
};
istream &operator>>(istream &in, Mi7 &x) {
in >> x.inner;
return in;
}
ostream &operator<<(ostream &out, Mi7 &x) {
out << x.inner;
return out;
}
inline void read(Mi7 &x) { x = read(); }
inline void write(Mi7 x) { write(x.inner); }
inline void writeln(Mi7 x) {
write(x);
putchar('\n');
}
inline void reads(Mi7 *a, int n) {
Fi { read(a[i]); }
}
inline void writes(Mi7 *a, int n) {
Fi {
write(a[i]);
putchar(' ');
}
putchar('\n');
}
struct Mi9 {
ll inner;
Mi9() : inner(1) {}
Mi9(ll x) : inner(FM(x, Pr9)) {}
Mi9 operator+(Mi9 x) { return PM(inner, x.inner, Pr9); }
Mi9 operator-(Mi9 x) { return MM(inner, x.inner, Pr9); }
Mi9 operator*(Mi9 x) { return FM(inner * x.inner, Pr9); }
Mi9 operator~() { return FMP(inner, Pr9 - 2, Pr9); }
Mi9 operator/(Mi9 x) { return FM(inner * (~x).inner, Pr9); }
};
istream &operator>>(istream &in, Mi9 &x) {
in >> x.inner;
return in;
}
ostream &operator<<(ostream &out, Mi9 &x) {
out << x.inner;
return out;
}
inline void read(Mi9 &x) { x = read(); }
inline void write(Mi9 x) { write(x.inner); }
inline void writeln(Mi9 x) {
write(x);
putchar('\n');
}
inline void reads(Mi9 *a, int n) {
Fi { read(a[i]); }
}
struct Cpl {
ld real, imag;
Cpl() : real(0), imag(0) {}
Cpl(ld x) : real(x), imag(0) {}
Cpl(ld x, ld y) : real(x), imag(y) {}
Cpl operator+(Cpl x) { return Cpl(real + x.real, imag + x.imag); }
Cpl operator-(Cpl x) { return Cpl(real - x.real, imag - x.imag); }
Cpl operator*(Cpl x) {
return Cpl(real * x.real - imag * x.imag,
real * x.imag + imag * x.real);
}
Cpl operator~() { return Cpl(real, -imag); }
Cpl operator/(Cpl x) {
ld d = x.real * x.real + x.imag * x.imag;
return Cpl((real * x.real + imag * x.imag) / d,
(imag * x.real - real * x.imag) / d);
}
ld abs() { return sqrt(real * real + imag * imag); }
};
inline void read(Cpl &x) {
x.real = read();
x.imag = read();
}
inline void write(Cpl x) {
write(x.real);
putchar(' ');
write(x.imag);
}
inline void writeln(Cpl x) {
write(x);
putchar('\n');
}
inline void reads(Cpl *a, int n) {
Fi { read(a[i]); }
}
inline void yon(bool x) {
if (x)
puts("yes");
else
puts("no");
}
inline void YoN(bool x) {
if (x)
puts("Yes");
else
puts("No");
}
inline void YON(bool x) {
if (x)
puts("YES");
else
puts("NO");
}
inline void ToA(bool x) {
if (x)
puts("Takahashi");
else
puts("Aoki");
}
int main() {
int T = read();
while (T --) {
ll a = read(), b = read(), ans = linf;
F(i, 0, (int)1.5e6) {
ans = min(ans, (b + a + i - 1) / (a + i) * (a + i) - b + i);
}
writeln(ans);
}
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
B - Make Divisible |
| ユーザ |
luhouxi |
| 言語 |
C++ (GCC 9.2.1) |
| 得点 |
0 |
| コード長 |
6197 Byte |
| 結果 |
WA |
| 実行時間 |
1301 ms |
| メモリ |
3616 KiB |
コンパイルエラー
./Main.cpp: In function ‘long long int read()’:
./Main.cpp:49:22: warning: unused variable ‘t’ [-Wunused-variable]
49 | ll x = 0, d = 1, t = 1;
| ^
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00-sample-001.txt |
| All |
00-sample-001.txt, 01-random-001.txt, 01-random-002.txt, 01-random-003.txt, 01-random-004.txt, 01-random-005.txt, 01-random-006.txt, 01-random-007.txt, 01-random-008.txt, 01-random-009.txt, 01-random-010.txt, 01-random-011.txt, 01-random-012.txt, 01-random-013.txt, 01-random-014.txt, 01-random-015.txt, 02-random-001.txt, 02-random-002.txt, 02-random-003.txt, 02-random-004.txt, 02-random-005.txt, 03-test-001.txt, 03-test-002.txt, 03-test-003.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00-sample-001.txt |
AC |
82 ms |
3520 KiB |
| 01-random-001.txt |
WA |
1299 ms |
3400 KiB |
| 01-random-002.txt |
WA |
1293 ms |
3468 KiB |
| 01-random-003.txt |
WA |
1292 ms |
3616 KiB |
| 01-random-004.txt |
WA |
1301 ms |
3572 KiB |
| 01-random-005.txt |
WA |
1295 ms |
3332 KiB |
| 01-random-006.txt |
AC |
1293 ms |
3552 KiB |
| 01-random-007.txt |
AC |
1294 ms |
3468 KiB |
| 01-random-008.txt |
AC |
1295 ms |
3520 KiB |
| 01-random-009.txt |
AC |
1293 ms |
3544 KiB |
| 01-random-010.txt |
AC |
1295 ms |
3392 KiB |
| 01-random-011.txt |
WA |
1292 ms |
3568 KiB |
| 01-random-012.txt |
WA |
1297 ms |
3468 KiB |
| 01-random-013.txt |
WA |
1295 ms |
3552 KiB |
| 01-random-014.txt |
WA |
1294 ms |
3380 KiB |
| 01-random-015.txt |
WA |
1295 ms |
3396 KiB |
| 02-random-001.txt |
WA |
1293 ms |
3532 KiB |
| 02-random-002.txt |
WA |
1293 ms |
3536 KiB |
| 02-random-003.txt |
WA |
1296 ms |
3324 KiB |
| 02-random-004.txt |
WA |
1294 ms |
3524 KiB |
| 02-random-005.txt |
WA |
1292 ms |
3552 KiB |
| 03-test-001.txt |
AC |
1292 ms |
3616 KiB |
| 03-test-002.txt |
WA |
48 ms |
3340 KiB |
| 03-test-003.txt |
AC |
1298 ms |
3612 KiB |