题解:CF2241B Good times Good times

· · 题解

被 cloudflare 卡了

思路

注意到 1\le x\le 10^8,2\le y\le 10^9,y 的上限刚好是 x 的上限的 10 倍,所以我们可以构造:一个 1 加若干个 0 再加一个 1 这样一个数,其中 0 的个数是 x 的长度减一,那么这样原数是好数,乘起来的数则是 x 重复两遍,仍然是好数。

submission

#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f3f3f3f3f
#define elif else if
using namespace std;
int x;
void solve(){
    cin>>x;
    cout<<1;
    x/=10;
    while(x){
        cout<<0;
        x/=10;
    }
    cout<<"1\n";
}
signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int Case=1;
    cin>>Case;
    while(Case--)solve();
}