公式
A - Attach 00 解説
by
A - Attach 00 解説
by
sheyasutaka
考察
\(100K\) は必ず末尾に 00 を持つため,条件を満たします.
したがって,\(cK\) (\(1 \leq c \leq 100\)) を総当たりすれば十分です.
実装例 (C++)
#include <iostream>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
#include <vector>
using std::vector;
#include <string>
using std::string;
using std::to_string;
#ifdef DEBUG
const int debug = 1;
#else
const int debug = 0;
#endif
typedef long long int ll;
void output (const ll x) {
cout << x << "\n";
}
ll k;
void solve() {
ll ans = 0;
for (ll i = 1; i <= 100; i++) {
string s = to_string(k * i);
if (s.find("00") != string::npos) {
ans = k * i;
break;
}
}
output(ans);
}
int main (void) {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
int T;
cin >> T;
for (int ti = 0; ti < T; ti++) {
cin >> k;
solve();
}
return 0;
}
投稿日時:
最終更新:
