题目描述
(看不清图片可以右击图片-> 复制图片地址 ->浏览器新开一个标签页,粘贴此地址就可看大图
(也可以右击图片-> 在新标签页打开图片
题解
题意:给你一个整型x(x <= 100), 让你输出一个整型y, y要满足3个条件:
- y 能被 x 整除
- y和各个数位的数字之和能被 x 整除(就是个位, 十位, 百位,… 之和)
- y的位数不超过 10^4
思维题, 真是太妙了。
最简单的构造方法就是, 把n看做字符串, 输出n个头尾相连的字符串n即可。
1
2
3
4
|
举个例子
x = 99
y = 99个99
用竖式除一下, 就是(1010101...)
|
1
2
3
4
|
举个例子
x = 99
y = 99个99
求和就是99个(18)
|
- 第三个条件, x最大是100, 100个100正好10 ^ 4
AC代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <set>
#include <map>
#include <ctime>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define eps 1e-8
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 5;
const int M = 1e9 + 5;
const int mod = 998244353;
int main(){
ios::sync_with_stdio(0);
int t, n;
cin >> t;
while(t--){
cin >> n;
for (int i = 1; i <= n; i++){
cout << n;
}
cout << "\n";
}
return 0;
}
|
1
|
恰似你一低头的温柔,娇弱水莲花不胜寒风的娇羞, 我的心为你悸动不休。 --mingfuyan
|