您的位置:首页 > 理论基础 > 计算机网络

【 2017 ACM-ICPC 亚洲区(西安赛区)网络赛】C. Sum

2017-09-19 20:12 351 查看
Define the functionS(x)
for x is a positive integer.S(x)
equals to the sum of all digit of the decimal expression of
xx.
Please find a positive integer k
that S(k∗x)%233=0.

Input Format

First line an integer T, indicates the number of test cases
(T≤100).
Then Each line has a single integer x(1 \le x \le 1000000)
x(1≤x≤1000000)

indicates i-th test case.

Output Format

For each test case, print an integer in a single line indicates the answer. The length of the answer should not exceed
200020002000.
If there are more than one answer, output anyone is ok.

样例输入

1
1


样例输出

89999999999999999999999999


题目大意:

函数s(x)=x各位数字之和,给你一个x值,让你找到一个k满足s(x*k)%233=0

分析:

例如x=123,则令x*k=123123...123123(233个123),在左右两边均除以x(即除以123),最终得到结果

k=100100...1001(232个100,最后一位为1),模拟即可

#include<bits/stdc++.h>
#include <ctime>
using namespace std;
typedef long long ll;
const int MAXN = 1 * 1e5 + 500;
const ll M = 1e9 + 7;

char a[15];
int main()
{
///clock_t start_time = clock();

///clock_t end_time = clock();
///cout << "Running time is: " << static_cast<double>(end_time - start_time) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
std::ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--)
{
memset(a, 0, sizeof(a));
cin >> a;
int len = strlen(a);

for (int i = 0; i < 232; i++)
{
cout << "1";
for (int j = 1; j < len; j++)
{
cout << "0";
}
}
cout << "1" << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  思维 acm-icpc 网络赛