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

Define the function S(x)S(x) for xx is a positive integer. S(x)S(x) equals to the sum of all digit of the decimal expression of xx. Please find a positive integer kk that S(k*x)\%233=0S(k∗x)%233=0.
Input Format
First line an integer TT, indicates the number of test cases (T \le 100T≤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 20002000. If there are more than one answer, output anyone is ok.
样例输入
1
1
样例输出
89999999999999999999999999



这道题目的意思是说有一个函数S(x)的值是一个数的十进制表示,所有位数之和。
现在S(k*x)%233=0;问你K的值是多少。
当X=1的时候,K=89999999999999999999999999,S(k*x)=233
就符合条件。

这道题目就是个脑洞题,想到构造方法就可以了。
我们想到的构造方法是,1001*123=123123
那么我们就只需要233个123就一定是满足条件的
那么我们只需要233个1001这样的循环节,在乘以X以后就变成了一个233个123的数。

这样的数的位数和一定是可以整除233的。


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while (t--) {
        int x;
        scanf("%d",&x);
        int len=0;
        while (x) {
            len++;
            x=x/10;
        }
        len--;
        for (int i=1;i<=232;i++) {
            printf("1");
            for (int j=1;j<=len;j++)
            printf("0");
        }
        printf("1\n");
    }
    return 0;
}



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值